有没有办法从另一个取消boost :: thread,如下所示?:
boost::thread* thread1(0);
boost::thread* thread2(0);
thread2 = new boost::thread([&](){
//some expensive computation that can't be modified
if(thread1)
thread1->interrupt();
});
thread1 = new boost::thread([&]() {
//some other expensive computation that can't be modified
if(thread2)
thread2->interrupt();
});
thread1->join();
thread2->join();
delete thread1;
delete thread2;
Run Code Online (Sandbox Code Playgroud)
现在,两个昂贵的计算都完成而不会被打断.我认为连接将被视为中断点,主线程将在完成两个昂贵的计算之一后继续.
| 归档时间: |
|
| 查看次数: |
378 次 |
| 最近记录: |