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…)
More Related Contents:
- How can I get my threaded program to print specific output
- Loop doesn’t see value changed by other thread without a print statement
- Avoid synchronized(this) in Java?
- Is multi-thread output from System.out.println interleaved
- Synchronizing on String objects in Java
- Synchronization vs Lock
- What is the difference between atomic / volatile / synchronized?
- How to synchronize a static variable among threads running different instances of a class in Java?
- How do I make my ArrayList Thread-Safe? Another approach to problem in Java?
- How do synchronized static methods work in Java and can I use it for loading Hibernate entities?
- Are Java static initializers thread safe?
- Java double checked locking
- Java Synchronized Block for .class
- Java Singleton and Synchronization
- Printing Even and Odd using two Threads in Java
- What is the difference between a synchronized method and synchronized block in Java? [duplicate]
- Sharing a variable between multiple different threads
- Should you synchronize the run method? Why or why not?
- Is synchronization within an HttpSession feasible?
- Why do I need to synchronize a list returned by Collections.synchronizedList
- Why must wait() always be in synchronized block
- Killing thread after some specified time limit in Java
- Choose between ExecutorService’s submit and ExecutorService’s execute
- java.lang.IllegalMonitorStateException: object not locked by thread before wait()?
- When is a Java thread alive?
- How to stop a thread created by implementing runnable interface?
- Java Thread Example? [closed]
- How can a Thread return a value after finishing its job?
- Jboss Java EE container and an ExecutorService
- Java getting download progress