class Thread
{
public:
Thread (DWORD (WINAPI * pFun) (void* arg), void* pArg)
{
_handle = CreateThread (
0, // Security attributes
0, // Stack size
pFun,
pArg,
CREATE_SUSPENDED,
&_tid);
}
~Thread() { CloseHandle (_handle); }
void Resume() { ResumeThread (_handle); }
void WaitForDeath()
{
WaitForSingleObject (_handle, 2000);
}
private:
HANDLE _handle;
DWORD _tid; // thread id
};
どのようにWaitForDeath()がスレッドを強制終了できますか?WaitForDeath()はどのようにしてサンプルのスレッドを強制終了できますか?
クラスの使用方法を示す必要があります。 –