std::thread::~thread

来自cppreference.com
< cpp‎ | thread‎ | thread
 
 
并发支持库
线程
(C++11)
(C++20)
this_thread 命名空间
(C++11)
(C++11)
(C++11)
协作式取消
互斥
通用锁管理
(C++11)
(C++11)
(C++11)
(C++11)
条件变量
(C++11)
信号量
闩与屏障
(C++20)
(C++20)
未来体
(C++11)
(C++11)
(C++11)
安全回收
风险指针
原子类型
(C++11)
(C++20)
原子类型的初始化
(C++11)(C++20 弃用)
(C++11)(C++20 弃用)
内存定序
(C++11)(C++26 弃用)
原子操作的自由函数
原子标志的自由函数
 
 
~thread();
(C++11 起)

销毁线程对象。

*this 拥有关联线程(joinable() == true),则调用 std::terminate()

注解

在下列操作后线程对象无关联的线程(从而可安全销毁)

示例

#include <thread>
using namespace std::chrono_literals;
 
int main()
{
    auto bleah = std::thread{[]{ std::this_thread::sleep_for(13ms); }};
 
}   // ~thread 调用 std::terminate()

可能的输出:

terminate called without an active exception

参阅

如果线程可合并,那么请求停止然后合并此线程。
(std::jthread 的公开成员函数)