スレッドを次のように中断したいと考えています。ブーストスレッドを中断する
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'ですか? –
@ AdriC.S。はい。私はそれを修正します。 –