wait until all threads finish their work in java

后端 未结 16 2184
情深已故
情深已故 2020-11-22 14:10

I\'m writing an application that has 5 threads that get some information from web simultaneously and fill 5 different fields in a buffer class.
I need to validate buffer

16条回答
  •  庸人自扰
    2020-11-22 14:48

    You do

    for (Thread t : new Thread[] { th1, th2, th3, th4, th5 })
        t.join()
    

    After this for loop, you can be sure all threads have finished their jobs.

提交回复
热议问题