#include
#include
void eric(int a,int b);
//HANDLE mutex;
DWORD WINAPI ThreadProc(LPVOID lpParameter)
{
long sum=0;
char c= (char)lpParameter;
for(long i=0;i<50000000000 i="i" p="p"> {
//::WaitForSingleObject(mutex,INFINITE);
//printf("%c",c);
sum += rand();
eric(1,2);
//::ReleaseMutex(mutex);
}
return 0;
}
int main(int argc,char* argv[])
{
//mutex=::CreateMutex(NULL,NULL,NULL);
const int nThreads=4;
unsigned long id[nThreads];
HANDLE tHandle[nThreads];
for(int i=0;i
id[i]=1;
tHandle[i]=::CreateThread(NULL,1024,ThreadProc,(void*)('a'+i),NULL,&id[i]);
}
::WaitForMultipleObjects(nThreads,tHandle,true, INFINITE);
return 0;
}
void eric(int a, int b)
{ long x;
x=a+b;
//eric(x,1);
return;
}