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