Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DWORD _stdcall TestThread (LPVOID param){
- ThreadParams *t = (ThreadParams*) param;
- cout << "thread created!: " << t->threadNum << endl;
- return 0;
- }
- CC cc;
- HANDLE thread[5000];
- ThreadParams t[5000];
- for (int i = 0; i < ThreadNum; i++){
- t[i].cc = &cc;
- t[i].threadNum = i;
- if ((thread[i] = CreateThread(NULL, 8192, TestThread, &t[i], 0, NULL)) == NULL ){
- printf("Failed to create thread %d, error %d\n", i, GetLastError());
- exit(-1);
- }
- }
- for (int i = 0; i < ThreadNum; i++) {
- WaitForSingleObject(thread[i], INFINITE);
- CloseHandle(thread[i]);
- }
Advertisement
Add Comment
Please, Sign In to add comment