有的人说这个函数会自动释放?
要不要调用WaitForSingleObject?如何不调用这个函数会怎样?
需要CloseHandle吗?

解决方案 »

  1.   

    线程结束后就自己释放了,不用closehandle
    waitforsingleobject是同步用的,调不调是根据同步需求来的。
      

  2.   

    最好用CloseHandle关闭一些,如果你开的线程多,不关闭的话,有可能会造成句柄泄露
      

  3.   

    让线程自己退出,然后closehandle
      

  4.   

    应该调用_endthreadex,而不是closehandle.
      

  5.   

    however, _endthread or _endthreadex is called automatically when the thread returns from the routine passed as a parameter to _beginthread or _beginthreadex. 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. (This behavior differs from the Win32 ExitThread API.) Therefore, when you use _beginthread and _endthread, do not explicitly close the thread handle by calling the Win32 CloseHandle API.