wait until all threads finish their work in java

后端 未结 16 2232
情深已故
情深已故 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:53

    Store the Thread-objects into some collection (like a List or a Set), then loop through the collection once the threads are started and call join() on the Threads.

提交回复
热议问题