VS2010 - C - process.h - 以_beginthread开头的"加入"线程

use*_*331 1 c multithreading join visual-studio-2010

我第一次尝试使用Windows的线程库(在VS2010中).但我想我错过了什么......我如何加入创建的线程?当线程仍在运行时,如何防止main() - Programm(或其他"更高"函数)退出?希望有人可以帮我解决问题或链接(msdn和其他一些人没有帮助).谢谢!

Jab*_*cky 5

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

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