我想能夠中斷一個線程如下。中斷提升線程
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