std::thread::~thread
来自 cppreference.cn
| ~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 calls std::terminate()
可能的输出
terminate called without an active exception
[编辑] 参阅
| 如果线程可连接,则请求停止并连接线程 ( std::jthread 的公开成员函数) |