Good day everyone. I have a general question relating to threads and the necessary steps to correctly "shutdown" a thread.
Just quick pseudocode:
The line pointed to by the red arrow. Is this required before using the same handle object to create another thread? Or can this call be omitted and just called once upon program termination? Basically wondering about the leaking of GDI resources.Code:HANDLE thread; thread = CreateThread(task1); WaitForSingleObject(thread); closeHandle(thread); <-------- thread = CreateThread(task2); DWORD task1() <--- Thread routine 1. DWORD task2() <--- Thread routine 2.
Oh I was also wondering. I am quite often shutting down the thread and re-creating it using another processing routine. (Note: Each processing routine does not run in parallel) Should I constantly be shutting down the thread and creating it or just have multiple threads that never shutdown (just suspend) one for each routine or just try and use the one thread to try and handle all routines in there so it lasts the lifetime of the program.? Sorry if this question sounds confusing.