// 2.1.2.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include #include #define nmax 10000 int sum; int t[nmax]; #define threadCount 4 //Critical section CRITICAL_SECTION cs; DWORD WINAPI ThreadFunc(LPVOID lpdwParam) { int tid = (int)lpdwParam; int s = 0; int i; int dn = nmax / threadCount; int start = tid * dn; int stop = tid != threadCount - 1 ? (tid + 1)*dn : nmax; for (i = start; i