更新时间:2023-12-05 10:09:52
最接近的是 std::thread::joinable()
.从参考中引用:
The closest you can get is std::thread::joinable()
. To cite from the reference:
检查线程对象是否标识了一个活动的执行线程.具体来说,如果 get_id() != std::thread::id()
,则返回 true
.所以默认构造的 thread
是不可连接的.
已完成代码执行但尚未加入的线程仍被视为活动的执行线程,因此是可加入的.
Checks if the thread object identifies an active thread of execution. Specifically, returns
true
ifget_id() != std::thread::id()
. So a default constructedthread
is not joinable.
A thread that has finished executing code, but has not yet been joined is still considered an active thread of execution and is therefore joinable.