Can C++11 tell if std::thread is active?

前端 未结 2 1937
醉梦人生
醉梦人生 2021-01-05 14:32

To my surprise, a C++11 std::thread object that has finished executing, but has not yet been joined is still considered an active thread of execution. This is illustrated in

2条回答
  •  佛祖请我去吃肉
    2021-01-05 15:14

    for what definition of "actively running code"? not that I know of, I'm not sure what state the thread is left in after it becomes joinable, in most cases I can think of you'd actually want fine grain control, like a flag set by the code running in that thread, anyway

    for a platform specific solution, you could use GetThreadTimes

提交回复
热议问题