我想能够中断一个线程如下。中断提升线程
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对象是不确定的,当我试图中断它是不可能的。我怎样才能解决这个问题?
在第一个代码的'else if'中不应该是'isStop'或类似的东西或者'isStart'? – 2012-12-18 16:47:14
@ AdriC.S。是。我会解决它。 – 2012-12-19 10:56:50