gpt4 book ai didi

c - VS2010 - C - process.h - "joining"线程以 _beginthread 开始

转载 作者:太空宇宙 更新时间:2023-11-04 01:02:53 24 4
gpt4 key购买 nike

我是第一次尝试使用 Windows(在 VS2010 中)的线程库。但我想我遗漏了一些东西......我如何加入创建的线程?当线程仍在运行时,如何防止 main()-Programm(或其他“高级”函数)退出?希望有人可以帮助我回答或链接(msdn 和其他一些人没有帮助)。谢谢!

最佳答案

未经测试,无错误检查代码:

HANDLE hThread = (HANDLE)_beginthread(Thread, 0, NULL);
WaitForSingleObject(hThread, INFINITE); // wait until the thread has finished

关于c - VS2010 - C - process.h - "joining"线程以 _beginthread 开始,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31678065/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com