////并没有释放互斥体,为什么打开的互斥体没作用?#include<windows.h>
#include<iostream>
using namespace std;
class CWorkerThread
{
public:
HANDLE m_hThread; HANDLE myMutexHandle;    int ThreadID;

public:

CWorkerThread():
  ThreadID(0),myMutexHandle(NULL),m_hThread(INVALID_HANDLE_VALUE){}

  
 void CreatMyThread()
  {
    CreateMutex(NULL,TRUE,NULL);//创建一个互斥体 cout<<"创建一个线程"<<endl; m_hThread = ::CreateThread(NULL,
                                     0,
 ThreadProc,
 reinterpret_cast<LPVOID>(this),
 0,
 NULL);
 }
  HANDLE OpenMyMutex()
  {
  myMutexHandle = OpenMutex(EVENT_ALL_ACCESS,TRUE,NULL);
  return myMutexHandle;
  } void MakeMutex()
{
cout<<"制造一个互斥体"<<endl;  myMutexHandle = CreateMutex(NULL,FALSE,NULL);
}
       
    static DWORD WINAPI ThreadProc(LPVOID lpParam)
     {
CWorkerThread* pThis = reinterpret_cast<CWorkerThread*>(lpParam);
        pThis->DoStuff();

    return 0;
     } protected:
virtual void DoStuff()
{
Sleep(2000);
cout<<"线程结束!"<<endl;
ExitThread(1);
    }

};void main()
{ CWorkerThread myThread;//创建一个对象

myThread.MakeMutex();
myThread.OpenMyMutex();
myThread.CreatMyThread();//创建一个线程
//并没有释放互斥体,为什么打开的互斥体没作用?
WaitForSingleObject(myThread.myMutexHandle,INFINITE);
  

    WaitForSingleObject(myThread.m_hThread,INFINITE);
cout<<"OVER"<<endl;
}//main