#include <iostream>
#include <Windows.h>
using namespace std;
int sum = 100;
DWORD WINAPI threadfun(LPVOID lpParameter);
int temp =1;
HANDLE m_mutex;
HANDLE handle1;
HANDLE handle2;
HANDLE handle3;
HANDLE handle4;
CRITICAL_SECTION g_cs;
int main()
{
char pmsg1[10] = "hello_1\n";
char pmsg2[10] = "hello_2\n";
char pmsg3[10] = "hello_3\n";
char pmsg4[10] = "hello_4\n";
// m_mutex = ::CreateMutex(NULL, FALSE, NULL);
// if(!m_mutex)cout<<"CreateMutex fail"<<endl;
handle1 = CreateThread(NULL,0,threadfun,(void*)pmsg1,0,NULL);
handle2 = CreateThread(NULL,0,threadfun,(void*)pmsg1,0,NULL);
handle3 = CreateThread(NULL,0,threadfun,(void*)pmsg1,0,NULL);
handle4 = CreateThread(NULL,0,threadfun,(void*)pm
vc 多线程处理临界数据,
最新推荐文章于 2019-10-17 17:16:43 发布