标签:long pause rlock bsp 线程 nbsp code eth div
#include "stdafx.h" #include <windows.h> int g_count; const int ThreadNum = 10; DWORD __stdcall Func(LPVOID pm) { Sleep(10); g_count++; //InterlockedIncrement((LPLONG)&g_count); return 0; } int main() { HANDLE handle[ThreadNum]; for (int k = 0; k < ThreadNum; ++k) { g_count = 0; for (int i = 0; i < ThreadNum; ++i) { handle[i] = CreateThread(NULL, 0, Func, (LPVOID)i, 0, NULL); } WaitForMultipleObjects(ThreadNum, handle, TRUE, INFINITE); printf_s("%d\n", g_count); } system("pause"); return 0; }
标签:long pause rlock bsp 线程 nbsp code eth div
原文地址:http://www.cnblogs.com/July7th/p/6241301.html