创建线程时遇到的问题:堆上和栈上的区别

cj1205 cj1205 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
m_hThread = CreateThread(NULL, 0, m_pThreadFunction, this, dwCreationFlags, &dwCreationFlags);

这段代码在堆上运行没有问题,但是在栈里面运行 m_hThread为NULL,谁知道为什么?
 int _tmain(int argc,char *argv[],char *envp[])
{
CSocketThread *threadone = new CSocketThread();
threadone->Start();
CSocketThread threadtwo;
threadtwo.Start(0);
system("pause");
return 0;
}

是否是生存期的问题?
...全文

相关推荐

评论 18
收藏 已收藏
分享
返回顶部
cj1205
进程/线程/DLL 15,465 成员 49,169 内容