WINDOWS 多线程的一点小实验

 

WINDOWS 多线程的一点小实验

 

 

 

#include #include DWORD WINAPI ThreadFun(LPVOID lp) { char *count=(char*)lp; (*count)++; printf("%d/n",*count); Sleep(100000); return 0; } int main() { HANDLE hThread1,hThread2; char count=0; hThread1=CreateThread(NULL,0,ThreadFun,&count,0,NULL); hThread2=CreateThread(NULL,0,ThreadFun,&count,0,NULL); printf("%d/n",hThread1); printf("%d/n",hThread2); CloseHandle(hThread1); CloseHandle(hThread2); Sleep(10000); return 0; }

 

结果:

2024

2036

1

2

你可能感兴趣的:(WINDOWS 多线程的一点小实验)