Making the main thread wait till all other Qthread finished

前端 未结 2 623
遥遥无期
遥遥无期 2021-01-17 23:31

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:56

    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).

提交回复
热议问题