Making the main thread wait till all other Qthread finished

前端 未结 2 546
忘掉有多难
忘掉有多难 2021-01-17 23:02

is there a way to force the main thread to wait until all threads created from it, will finish their job, before finishing the program. I mean:

int main(){
          


        
2条回答
  •  天命终不由人
    2021-01-17 23:46

    Well, what about:

    a.wait();
    b.wait();
    

    Or, you would rather start an event loop (as usually for Qt applications) that you quit when both of your threads end (QThread emits finished() and terminated() signals).

提交回复
热议问题