std::jthread::~jthread

< cpp‎ | thread‎ | jthread
~jthread();
(C++20 起)

销毁 jthread 对象。

*this 拥有关联线程(joinable() == true),则调用 request_stop() 然后 join()

注解

若此 jthread 先前已被请求停止则 request_stop() 无效果。

jthread 对象在下列操作后无关联线程

  • 它被默认构造
  • 它被移动
  • 已调用 join()
  • 已调用 detach()

如果 join() 抛出一个异常(比如:因为检测到了死锁),std::terminate() 也许会被调用。

示例

参阅

析构线程对象,必须合并或分离底层线程
(std::thread 的公开成员函数)