【发布时间】:2013-04-15 13:46:14
【问题描述】:
我正在使用boost::thread join 方法等待线程完成。但是,如果我在线程已经完成时尝试 join 线程,我会收到异常。那我该怎么做:
如果活跃则加入线程,如果不活跃则不执行任何操作?
【问题讨论】:
-
这个帖子可能会有所帮助:stackoverflow.com/questions/1667420/…
-
你确定没有其他事情发生吗?在手册中它说
If the thread of execution represented by the boost::thread object has already completed, or the boost::thread object represents Not-a-Thread, then join() returns immediately.