[whatwg] WebWorkers vs. Threads
aa at google.com
Mon Aug 11 10:43:29 PDT 2008
On Sun, Aug 10, 2008 at 5:54 PM, Shannon <shannon at arc.net.au> wrote:
> * each coroutine gets a real OS thread (if available).
Coroutines in Lua are not operating system threads or processes.
Coroutines are blocks of Lua code which are created within Lua, and
have their own flow of control like threads. Only one coroutine ever
runs at a time, and it runs until it activates another coroutine, or
yields (returns to the coroutine that invoked it). Coroutines are a
way to express multiple cooperating threads of control in a convenient
and natural way, but do not execute in parallel, and thus gain no
performance benefit from multiple CPU's. However, since coroutines
switch much faster than operating system threads and do not typically
require complex and sometimes expensive locking mechanisms, using
coroutines is typically faster than the equivalent program using full
Is this description incorrect? It seems at odds with what you said
about Lua coroutines getting an OS thread (if one is available).
More information about the whatwg