6
如何等待線程在Windows中死亡?這是我想讓我的代碼看起來像:在Windows中加入等效物
main thread:
creating thread: thread1
waiting for thread1 to die
//rest of the code
我正在使用Win32 API。
+0
如何等待線程在Windows中死亡?這是我想讓我的代碼看起來像:在Windows中加入等效物
main thread:
creating thread: thread1
waiting for thread1 to die
//rest of the code
我正在使用Win32 API。
很簡單:WaitForSingleObject可以阻止給定另一個線程的句柄的當前線程。
void Thread1Proc()
{
HANDLE hThread2 = CreateThread(...);
WaitForSingleObject(hThread2, INFINITE);
// by now thread #2 is over
}