65,210
社区成员
发帖
与我相关
我的任务
分享void sub_thread() //在该子线程里开启子线程列表
{
list<thread* > thread_list;
while(1)
{
等待接受信号:xxx
if(xxx==stop)
{
for(auto t:thread_list)
{
t->join() // 在这里卡住,走不到下一步
下一步操作
}
}else
{
thread_list.push_back(new thread(...)); //j加入新线程
}
}
}
int main()
{
while(1)
{
等待接受信号:xxx
thread th(sub_thread()); //开启线程,并独立出来
th.detach();
}
}