[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: What's the difference between a "coroutine" and a "thread" in Lua?
- From: "Duncan Cross" <duncan.cross@...>
- Date: Fri, 10 Aug 2007 09:21:32 +0100
On 8/10/07, John Klimek <jklimek@gmail.com> wrote:
> I'm a little confused because the terms "coroutine" and "thread" are
> used somewhat interchangeably in the Lua documentation.
>
> Are Lua "coroutines" and "threads" the same exact thing?
>
> Thanks...
>
No. Threads are the underlying thing that coroutines are implemented
on top of. Coroutines are threads created in a particular way with a
specific target function, that can be resumed and yielded, but not all
threads are set up this way - if you create a thread via the C api
that has nothing on its stack, that is not (yet) a coroutine.