✓ Accepted answer
First: Lua does not have true threads.
Coroutines work by starting whenever everyone else is stopped -- that is, when I yield, someone else can go (just like traffic). wait, :wait() etc are the normal ways that scripts yield.
That means there is a significant cost to making new coroutines that will work constantly -- because for each one, more and more time is spent just waiting and managing who goes next.
(There is a good reason for this -- it avoids race conditions)
If what you want is to just create and run a new coroutine, spawn is probably the best because it is clear and simple. delay equivalently so if you only want to make a new coroutine that will start after a given time.
Coroutines can do more, though. For example, it is an easy way to think of them as iterators. In that case, you could use coroutine.wrap or coroutine.create and coroutine.resume. But if you aren't explicitly using coroutine.yield it's unlikely you'll benefit from it.
In that case, spawn or delay is probably preferable.
NOTE: there isn't a "correct answer" answer to this. My answer represents only one opinion, and I'm sure there are good reasons to disagree with this at least in some situations.
I am also of the opinion that in general spawning coroutines is bad. Usually it is better (and it is almost always faster) if you manage to do things from a single thread rather than from multiple -- especially because you avoid strange race conditions.
1 comment
There is this type of code where you use the 'return' keyword, as I have seen it before, but, however, I do not know how it works at all, as I have never really seen it in action. :/ [return function() code end)]