Timeout for thread.join()

前端 未结 5 2217
暗喜
暗喜 2020-12-01 15:44

Is it possible to set a timeout for a call to std::thread::join()? I want to handle the case in which the thread is taking too long to run, or terminate the th

5条回答
  •  佛祖请我去吃肉
    2020-12-01 16:20

    timed_join() is now deprecated. Use try_join_for() instead:

    myThread.try_join_for(boost::chrono::milliseconds(8000))
    

提交回复
热议问题