Waiting on multiple threads to complete in Java

Just join them one by one:

for (Thread thread : threads) {
  thread.join();
}

(You’ll need to do something with InterruptedException, and you may well want to provide a time-out in case things go wrong, but that’s the basic idea…)

Leave a Comment