Alex Rivera | Logout

Wait until all Java threads finish their work

Asked 2011-10-29T13:40:24.407
127

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

I need to validate the buffer data and then store it in a database when all threads finish their job.

How can I get alerted when all threads finished their work?

Edit
Report

1 Answer

4

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.

answered 2011-10-29T13:43:40.877

Your Answer