1
CreateThread
返回HANDLE
对象需要由CloseHandle
CreateThread的句柄泄漏
文档被关闭指出The thread object remains in the system until the thread has terminated and all handles to it have been closed through a call to CloseHandle.
我的问题是如果返回变量不使用会发生什么。它等于不关闭返回的句柄,并因为这与处理泄漏?这是对的吗?
避免希望仙女照顾它。如果一个winapi函数返回一个句柄,那么释放它就是你的工作。当然,你总是要检查通话是否失败。 –
除非您需要等待线程在稍后阶段退出,否则最简单的方法是在调用CreateThread之后调用CloseHandle(hThread),然后您不必再担心它。 – BrendanMcK