【发布时间】:2010-10-14 08:47:50
【问题描述】:
我正在阅读一些与线程相关的代码,并找到了这段代码:
MyThread::start()
{
//Create a thread
m_pThread = AfxBeginThread(/*some parameters*/)
//Create a duplicate handle for the created thread
m_hDuplicateHandle = DuplicateHandle(/* some more parameters*/)
}
MyThread::stop()
{
//Set some variables so that the thread comes out of its run() function
WaitForSingleObject(m_hDuplicateHandle, defaultTimeout);
CloseHandle(m_hDuplicateHandle);
}
我的问题,为什么需要重复句柄?我们不能直接等待原始线程句柄吗?它是否会变得无效?
【问题讨论】:
标签: c++ multithreading winapi mfc