我要初始化pthread_t
变量并在销毁类时检查此值。
例如:
class TestThread
{
public:
TestThread();
~TestThread();
void RunThread();
private:
pthread_t m_ptTest;
}
TestThread::TestThread()
{
m_ptThread = <initial value>
}
TestThread::RunThread()
{
pthread_create(&m_ptThread, NULL, ThreadRoutine, NULL);
}
TestThread::~TestThread()
{
if (m_ptThread != <initial value>)
pthread_join(m_ptThread, NULL);
}
在上面的示例中是否可以将initial value
设为0
或NULL
?