【发布时间】:2012-03-31 03:14:06
【问题描述】:
我希望能够如下中断线程。
void mainThread(char* cmd)
{
if (!strcmp(cmd, "start"))
boost::thread thrd(sender); //start thread
if (!strcmp(cmd, "stop"))
thrd.interrupt(); // doesn't work, because thrd is undefined here
}
thrd.interrupt() 是不可能的,因为当我尝试中断 thrd 对象时它是未定义的。我怎样才能解决这个问题?
【问题讨论】:
标签: c++ multithreading boost boost-thread