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

后端 未结 9 1008
无人及你
无人及你 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条回答
  •  Happy的楠姐
    2020-12-31 01:34

    You could make the last line be in a "monitoring" thread. It would check every so often that it is the only running thread and some completion state == true and then could fire if it was. Then it could do other things than just println

提交回复
热议问题