Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop program execution until threads complete

I have a console application that inits 4 theads to perform a long task. I want my program to wait until the threads are complete, and then complete the program execution. Is there a way to stop the program from executing, letting the threads complete their job?


2 Answers

Threading.Thread.Join is what you are looking for.

Edit: Examples here

like image 192
Pondidum Avatar answered Mar 12 '26 04:03

Pondidum


Load your application after those threads are joined e.g:

Thread1.join();
Thread2.join();
Thread3.join();
Thread4.join();


startApplication();

If you could provide me in more detail i can help you better.

like image 24
AZ_ Avatar answered Mar 12 '26 04:03

AZ_



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!