java threads and main thread

前端 未结 5 1281
遥遥无期
遥遥无期 2020-12-28 22:18

what\'s the best way to make main thread to wait until all threads are finished?

for(int i=0;i

        
5条回答
  •  一个人的身影
    2020-12-28 22:24

    I think for your requirement the best solution is the CyclicBarrier look at http://download.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/CyclicBarrier.html

    or

    at this example

提交回复
热议问题