Subj : Re: boost::thread d'tor does not call endthread To : comp.programming.threads From : dayton Date : Sat May 28 2005 09:20 am Hardy wrote: > ... What could be > possible repercussions of calling CloseHandle without calling > endthread? endthread() must be called from within the thread. endthread() does not terminate the thread on Windows. It merely clears up the C runtime library structures associated with the matching beginthread() or beginthreadex() call. The corresponding Win32 API call to the beginthread() functions is CreateThread(). CreateThread() knows nothing about C I/O, thus the need for beginthread(). Just merely returning from a thread function in Windows does the same thing as an endthread(). There is a Win32 API function, TerminateThread(). TerminateThread() does not run any clean up functions whatsoever. It is realy Terminate with Extreme Prejudice. C++ destructors won't get executed when you TerminateThread(). Closing the handle on a running thread merely turns the thread into an orphan. In this regard thread handles aren't like other Windows handles. You use the thread handle so that other threads can control your thread. You may use the thread handle even after the thread has returned from execution to query its status. .