I've been wondering if my program ever executes the following ...
Now my first thought was that anything below the while loop would never be executed. The reason why I put it there that way is because if I put it below either WaitForMultipleObjects() or CloseHandle() the functions within the loop never executed. So I put them before those and the program executes as planned. My question is this, if there is no way out of the infinite loop then does the handles stay open? Is there no way to close them _and_ keep my infinite loop going? Thanx.Code:HANDLE thread1=0, thread2=0, thread3=0, Array_Of_Thread_Handles[3]; thread1=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)function1,0,0,0); thread2=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)function2,0,0,0); thread3=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)function3,0,0,0); while(1){ // .. Looping some other important code // .. Looping again } Array_Of_Thread_Handles[0]=thread1; Array_Of_Thread_Handles[1]=thread2; Array_Of_Thread_Handles[2]=thread3; WaitForMultipleObjects(3,Array_Of_Thread_Handles,true,INFINITE); CloseHandle(thread1); CloseHandle(thread2); CloseHandle(thread3);




Reply With Quote