游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2419|回复: 0

lua的多线程问题,请指教^@^

[复制链接]

3

主题

186

帖子

190

积分

注册会员

Rank: 2

积分
190
发表于 2005-3-27 19:03:00 | 显示全部楼层 |阅读模式
在Lua的文档中关于Threads有这么一段描述:
  The following function creates a new thread in Lua:
        lua_State *lua_newthread (lua_State *L);
  This function pushes the thread on the stack and returns a pointer to a lua_State that represents this new thread. The new state returned by this function shares with the original state all global objects (such as tables), but has an independent run-time stack.
  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.

最开始看到这段话时我们认为有冲突,第一段说所有的state共享全局对象(写了测试程序,对于lua_set/gettable的LUA_GLOBALSINDEX,所有的state,无论是original state的还是用lua_newthread创建的new thread都是共享的)。但是后一段说每个线程都有一个独立的全局环境表,那么我想这个全局环境表和全局对象应该是分开的,但是我不知道如何去操作(set/get)这个全局环境表(global environment table),那么,我想对它进行操作,应该如何做呢?谢谢~~~
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-12-25 01:01

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表