Windows merge equivalent

How to wait until a thread dies in Windows? This is what I want my code to look like this:

main thread: creating thread: thread1 waiting for thread1 to die //rest of the code 

I am using the Win32 API.

+6
source share
1 answer

It's easy: WaitForSingleObject can block the current thread, given a different thread descriptor.

 void Thread1Proc() { HANDLE hThread2 = CreateThread(...); WaitForSingleObject(hThread2, INFINITE); // by now thread #2 is over } 
+20
source

Source: https://habr.com/ru/post/921954/


All Articles