How do I pause main() until all other threads have died?

后端 未结 9 898
无人及你
无人及你 2020-12-31 00:46

In my program, I am creating several threads in the main() method. The last line in the main method is a call to System.out.println(), which I don\'t want to call until all

9条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-31 01:17

    You can add a shutdown hook for the "Its Over" message. This way it will be produced when the program finishes and you don't have to wait for each thread.

提交回复
热议问题