1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| #include <handleapi.h> #include <minwindef.h> #include <processthreadsapi.h> #include <stdio.h> #include <synchapi.h> #include <windows.h> #include <winnt.h>
DWORD WINAPI ThreadProc(LPVOID IpParameter){ for (int i = 0; i < 100; i++) { Sleep(50); printf("+++%d\n",i); } return 0; }
int main(int argc, char *argv[]) { HANDLE hThread[2]; DWORD dwR1,dwR2; hThread[0] = CreateThread(NULL, 0, ThreadProc, NULL,0, NULL); hThread[1] = CreateThread(NULL, 0, ThreadProc, NULL,0, NULL);
WaitForMultipleObjects(2, hThread, TRUE, INFINITE); GetExitCodeThread(hThread[0], &dwR1); GetExitCodeThread(hThread[1], &dwR2); printf("%lx %lx",dwR1,dwR2); return 0; }
|