设为首页 加入收藏

TOP

C++11 thread::joinable(5)
2015-07-20 17:45:16 来源: 作者: 【 】 浏览:1
Tags:thread::joinable
?

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

?
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇[ACM] hdu 3037 Saving Beans (Lu.. 下一篇Codeforces 208 B. Solitaire

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Shell 传递参数 (2025-12-25 00:50:45)
·Linux echo 命令 - (2025-12-25 00:50:43)
·Linux常用命令60条( (2025-12-25 00:50:40)
·nginx 监听一个端口 (2025-12-25 00:19:30)
·整个互联网就没有一 (2025-12-25 00:19:27)