The ID of the thread and the mutex object counter
void Main () {
HANDLE Handle to hthread1;//thread
HANDLE hThread2;
Hthread1=createthread (Null,0,fun1proc,null,0,null);
Hthread2=createthread (Null,0,fun2proc,null,0,null);
CloseHandle (HTHREAD1);//closes the handle and does not terminate the thread, indicating that the handle is not interested in the main thread.
When the handle is closed, the usage count of the thread kernel object of the new thread is decremented,
The usage count is also decremented when the thread finishes executing
When use count is 0 o'clock, the system releases the thread kernel object
CloseHandle (HTHREAD2);
Hmutex=createmutex (null,false,null);//Create an anonymous mutex object. False no thread owns the mutex object.
The operating system sets the mutex to a notified state, which is signaled
WaitForSingleObject (hmutex,infinite);//The same Mian main thread, Hmutex plus 1, became 2
ReleaseMutex (Hmutex);
ReleaseMutex (Hmutex);//Must be released two times to make the Hmutex ID 0, in order to enable two threads in multithreading-5 to request to the mutex object Sleep (4000);//The main thread abandons the execution power and enters the waiting state.
}