?
std::thread::joinable
bool joinable() const noexcept;
Check if joinable Returns whether the
thread object is
joinable.
返回线程对象是否是joinable的。
?
A
thread object is
joinable if it represents a thread of execution.
如果是一个正在执行的线程,那么它是joinable的。
?
A thread object is not joinable in any of these cases:
下列任一情况都是非joinable
if it was
default-constructed.
默认构造器构造的。if it has been moved from (either
constructing another
thread object, or
assigning to it).
通过移动构造获得的。if either of its members
join or
detach has been called.
调用了join或者detach方法的。
例子:
?
#include
#include
#include
using namespace std; void delay(double sec) { time_t start_time, cur_time; // 变量声明 time(&start_time); do { time(&cur_time); }while((cur_time - start_time) < sec ); }; void show(int n){ cout<
运行结果:
?
用GDB调试发现一个好神奇的东西。

运行完了
cout<
?
之后,居然像栈析解一样,好神奇阿,现在还不知道为什么呢。。
先保留着,下次解决。
?
?
?
Parameters
none
Return value
true if the thread is
joinable.
false otherwise.
Example