This topic has been archived. It cannot be replied.
-
工作学习 / 专业技术讨论 / 请教VC++ 多线程编程问题
-bobo123(bobo);
2006-12-9
{867}
(#3367561@0)
-
VC++忘了,说的不一定适用。你可以用static把生成线程的成员函数定义成全局的,把this指针作为线程环境参数传递进去。线程里面的栈变量是不受影响的,所有数据段变量踢到类里面。我先去买菜,回来给你找找我以前的代码,不过不是VC的。
-ccloafer(梦游加拿大);
2006-12-9
{52}
(#3367881@0)
-
See Header, ignoring the template part:
-ccloafer(梦游加拿大);
2006-12-9
{905}
(#3368381@0)
-
See Source:void * CGServer::ThreadFunc( void * para )
{
CG3Server* p_thisserver;
...............................................
*p_thisserver = (CGServer*)para;
pthread_setspecific( key_ServerInstance, (void *)p_clntmap );
}
(*p_thisserver)->Initialize();
(*p_thisserver)->RunServer();
(*p_thisserver)->UnInitialize();
return NULL;
}
-ccloafer(梦游加拿大);
2006-12-9
{394}
(#3368393@0)
-
之所以叫Thread就是因为stack是单独的,你在thread里面分配的内存其他thread并不能看到。
-canadiantire(轮胎-pax et lux);
2006-12-9
(#3367970@0)
-
class 的function的第一个缺省参数是this指针,除非it is static function.
So you can either change it to static or create a global function as mentioned by 梦游加拿大.
Otherwise the signature of the function would not match.
-kuailerensheng(happy);
2006-12-9
(#3368366@0)
-
谢谢以上各位的答复, 问题已经解决了.
-bobo123(bobo);
2006-12-10
(#3368910@0)