大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE稳定放心使用
// TestStorage.cpp : 定义控制台应用程序的入口点。
//
#include “stdafx.h”
#include <Windows.h>
#include <process.h>
//#define MUTEX_DBG
UINT WINAPI Thread1(LPVOID para)
{
#ifdef MUTEX_DBG
HANDLE* phMutex = (HANDLE*)para;
WaitForSingleObject(*phMutex,INFINITE);
#endif
printf(“Enter Thread1/n”);
printf(“I’m sleeping……/n”);
Sleep(1000);
printf(“Leave Thread1/n”);
#ifdef MUTEX_DBG
ReleaseMutex(*phMutex);
#endif
return 0;
}
UINT WINAPI Thread2(LPVOID para)
{
#ifdef MUTEX_DBG
HANDLE* phMutex = (HANDLE*)para;
WaitForSingleObject(*phMutex,INFINITE);
#endif
printf(“Enter Thread2/n”);
printf(“I’m sleeping……/n”);
Sleep(1000);
printf(“Leave Thread2/n”);
#ifdef MUTEX_DBG
ReleaseMutex(*phMutex);
#endif
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
HANDLE hMutex = NULL;
#ifdef MUTEX_DBG
hMutex = CreateMutex(NULL,FALSE,NULL);
#endif
HANDLE hThread1 = (HANDLE)::_beginthreadex(NULL,0,Thread1,&hMutex,0,NULL);
HANDLE hThread2 = (HANDLE)::_beginthreadex(NULL,0,Thread2,&hMutex,0,NULL);
Sleep(4000);
if(hThread1)
CloseHandle( hThread1 );
if(hThread2)
CloseHandle( hThread2 );
return 0;
}
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/185944.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...