lua-users home
lua-l archive

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

On Sat, Jun 13, 2020 at 2:05 PM James Pascoe <> wrote:
> Also, the reference manual states that Lua threads created by lua_newthread() share the same global environment, which (as I understand it) means that they point to the same global environment in the parent lua_State. However, what I am trying to understand is whether it is possible to run individual Lua threads in separate OS threads safely?

No, that's not possible to safely do with stock Lua. Different OS
threads running Lua at the same time can only safely use completely
separate states, not threads that share a global state.

> And also, is it possible for Lua threads running in separate OS threads to communicate?

On their own, separate Lua states can't communicate at all. You'd have
to use some kind of helper to communicate between them, like Lua Lanes
[1] or luaproc [2].


Joseph C. Sible