多线程中的join先后顺序问题
join会阻塞当前线程,但是如下实例的输出:
thread t1([](){
this_thread::sleep_for(chrono::milliseconds(500));
cout<<"t1"<<endl;
});
thread t2([](){
cout<<"t2"<<endl;
});
t1.join();
cout<<"main"<<endl;
t2.join();
输入先后为什么是:
t2 t1 main
编译工具:clang++
唐伯虎点雷管
9 years, 9 months ago