lua-users home
lua-l archive

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


On Tue, Aug 19, 2003 at 02:45:55PM +0600, Antero Vipunen wrote:
> I have such system:
>                 -> LuaThread1(= lua_newthread(MainLuaState))
> MainLuaState ---|
>                 -> LuaThread2(= lua_newthread(MainLuaState))
> 
> If I add globals to LuaThread2 they become accessable in LuaThread1 also. But I want to have vars with the same name
> butdifferent value in LuaThread1,LuaThread2.

As documented here:

http://www.lua.org/manual/5.0/manual.html#3.20

Threads start with the same globals, but that can be changed. See here:

http://www.lua.org/manual/5.0/manual.html#3.12

I.e: You will want to use lua_replace to replace the globals table for
each thread. You may or may not want to play some clever tricks to
make them share certain variables.

Jules