lua-users home
lua-l archive

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


Vyacheslav Kalitkin wrote:
>
> From manual: "Each thread has an independent global environment table. When
> you create a thread, this table is the same as that of the given state, but
> you can change each one independently."
> This is mean, if I change a value in main thread, this is will independently
> for a value for second thread?

No.  It means that:

	lua_replace(L, LUA_GLOBALSINDEX);  // and also setfenv(0, xxx)

is local to that L.  Other lua_States are unaffected.

As long as threads share their global table any change within that
table is visible in all of them.

> Second problem:
> L1=lua_open(); L2=lua_open()
> If I create string value "abc" in L1, then with "lua_xmove" copy to L2, this
> value~="abc" in L2 context

That will crash sometime later.  You can only xmove between lua_States
which descend from the same lua_open.

Ciao, ET.