多核编程与并行计算
}
CloseHandle(hMutex); return 0;
int main(int argc, char* argv[])
{
}
return 0; WaitForMultipleObjects(THREAD_INSTANCE_NUMBER,h,TRUE,INFINITE); cout << "Close the Mutex Handle! " << endl; CloseHandle(hMutex); } cout << "CreateThread error" << ID[i] << endl; cout << "CreateThread: " << ID[i] << endl; else h[i] = CreateThread(NULL, if (h[i] == NULL) 0, (LPTHREAD_START_ROUTINE) ThreadProc, (void *)&ID[i], 0, &(ID[i])); for (i=0;i<THREAD_INSTANCE_NUMBER;i++) { int i; DWORD ID[THREAD_INSTANCE_NUMBER]; HANDLE hMutex; if ( (hMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, "Mutex.Test")) == NULL) { } if ((hMutex = CreateMutex(NULL, FALSE, "Mutex.Test")) == NULL ) { } cout << "Create Mutex error!" << endl; return 0; HANDLE h[THREAD_INSTANCE_NUMBER];