Information, links, and notes about the pthreads-win32 library
You can call _endthread or _endthreadex explicitly to terminate a thread; however, _endthread or _endthreadex is called automatically when the thread returns from the routine passed as a parameter. Terminating a thread with a call to endthread or _endthreadex helps to ensure proper recovery of resources allocated for the thread. _endthread automatically closes the thread handle (whereas _endthreadex does not). Therefore, when using _beginthread and _endthread, do not explicitly close the thread handle by calling the Win32CloseHandle API. This behavior differs from the Win32ExitThread API. Note For an executable file linked with LIB, do not call the Win32 ExitThread API; this prevents the run-time system from reclaiming allocated resources. _endthread and _endthreadex reclaim allocated thread resources and then call ExitThread.I do not have a handle leak, so thread handles are being closed. But there does seem to be a significant memory leak. My application starts many short-lived threads. -- DaleBrayden - 14 Oct 2003