如何等待线程直到它开始运行

How to wait for a thread till it has started running

本文关键字:开始 运行 线程 何等待 等待      更新时间:2023-10-16

我目前有这样的东西

这是我班级的成员

 boost::shared_ptr<boost::thread_group> my_group;

在我的代码中的其他地方,我这样做

my_group->create_thread( boost::bind( &Myclass::method, this ) );

现在在上面的声明中,我有没有办法阻止/等待这个线程启动?如

wait for above thread to lauch and start
Do next stuff after that. 

因此,正如文档所说:

后置条件:this->size() 增加 1,新线程为 运行。

调用此成员函数后,线程已在运行。在那之后,你可以立即做你的下一件事。