How do I wait for a thread to die in Windows? This is what I want my code to look like:

main thread:

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

I am using Win32 API.

Edit
Report