Pls refer to the below Win32 code:
Here I can create 4 threads simultaneously, but to my knowledge the thread controlling function ("ThreadFunc") will be common to all the 4 threads. Now if one of the 4 threads becomes signaled (for example), then how do I process it inside the ("ThreadFunc") ?Code:#define THREADCOUNT 4 int main() { DWORD IDThread; HANDLE hThread[THREADCOUNT]; //Handle maximum of 4 threads int i; // Create multiple threads. for (i = 0; i < THREADCOUNT; i++) { hThread[i] = CreateThread(NULL, // default security attributes 0, // use default stack size (LPTHREAD_START_ROUTINE) ThreadFunc, // thread function NULL, // no thread function argument 0, // use default creation flags &IDThread); // returns thread identifier // Check the return value for success. if (hThread[i] == NULL) ErrorExit("CreateThread error\n"); } for (i = 0; i < THREADCOUNT; i++) WaitForSingleObject(hThread[i], INFINITE); return 0; }
Thanks,




Reply With Quote