69,322
社区成员
发帖
与我相关
我的任务
分享
那里有问题啊
class CMyMutex
{
HANDLE hMutex;
public:
CMyMutex()
{
hMutex=::CreateMutex(NULL,true,NULL); //第二个参数,创建线程拥有互斥体
};
~CMyMutex()
{
::ReleaseMutex(hMutex);
::CloseHandle(hMutex);
}
unsigned int MyThread1(void* )
{
//other code
CMyMutex mutex;
/*
dosomehing
*/
return 0;
}
unsigned int MyThread2(void* )
{
//other code
CMyMutex mutex;
/*
dosomehing
*/
return 0;
}
int main(int argc, char** argv)
{
{
CMyMutex mutex;
}
cout << "============" << endl;
return 0;
}