Can i kill a thread from the main thread that created it?
>can i kill a thread from the main thread that created it? >under Windows, i only found the CWinThread::ExitInstance () method, You can kill a thread with TerminateThread(). Using TerminateThread is really, really, really, really, not recommended. If thread owns a critical section the critical section is not released and it will forever be unaccessable. If other threads then try to enter it they will hang forever. Also, the stack allocated to the thread is not released and various other bad things can happen. If you think you need to use TerminateThread it’s a good sign that your threading design is broken. You should be telling the thread to exit itself. Figuring out how to call TerminateThread using MFC’isms such as CWinThread is left as an exercise to the reader. -Mike > Also, the stack allocated to the thread is not released > and various other bad things can happen. Yes, it’s that bad… A while ago I started writing an app that used TerminateThread() – it leaked about a megabyte