多核编程与并行计算
实验六:
// exa6.cpp : Defines the entry point for the console application. //
#include "stdafx.h"
#include <windows.h>
#include <iostream.h>
#define THREAD_INSTANCE_NUMBER 3
LONG g_fResourceInUse = FALSE;
LONG g_lCounter = 0;
DWORD ThreadProc(void * pData) {
cout << "ThreadProc: " << ThreadNumberTemp << " is running!" << endl; if ((hMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, "Mutex.Test")) == NULL) { } cout << "ThreadProc " << ThreadNumberTemp << " gets the mutex"<< endl; ReleaseMutex(hMutex); cout << "Open Mutex error!" << endl; int ThreadNumberTemp = (*(int*) pData); HANDLE hMutex;