有没有办法强制主线程等待,直到从它创建的所有线程都将完成它们的工作,然后才能完成程序。我的意思是:
int main(){
QthreadClass a; // in cons' a thread is created and running
QthreadClass b; // same as before
*** wish to wait till both created thread finished their jobs ***
return 0;
最佳答案
那么,关于:
a.wait();
b.wait();
或者,您宁愿启动一个事件循环(通常用于 Qt 应用程序),当您的两个线程都结束时(QThread 发出 finished() 和 terminated() 信号)退出。
关于c++ - 让主线程等到所有其他 Qthread 完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15324017/