lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, Jun 20, 2013 at 2:07 PM, David Demelier
<demelier.david@gmail.com> wrote:
> 2013/6/20 Javier Guerra Giraldez <javier@guerrag.com>:
>> On Thu, Jun 20, 2013 at 3:28 PM, Javier Guerra Giraldez
>> <javier@guerrag.com> wrote:
>>> you should read/modify/execute a single Lua State concurrently from two threads
>>
>>
>> ... and of course, by "you should..." i really meant "you should NOT...."
>>
>> --
>> Javier
>>
>
> So does the Lua VM store some static variables or so? Why it's not
> supported? My naive thoughts let me understand that if I use the state
> and leave it just like when I found it, it should continue working.
>
> Also, I didn't read something about thread issue in my PiL third
> edition, may be a notice should be added to the next book?
>
> Regards,
>
> --
> Demelier David
>

The Lua code is reentrant, but not threadsafe. If you have multiple
Lua states running on separate threads, they'll run just fine, but if
you use ONE Lua state on MULTIPLE threads, you have to make sure that
only one thread is ever in the Lua internals at the same time.

/s/ Adam