Wait for an array of threads to finish their processes - Java java.lang

Java examples for java.lang:Thread

Description

Wait for an array of threads to finish their processes

Demo Code


//package com.java2s;

public class Main {
    /**/*from  w w w  .  ja va 2s.  co  m*/
     * Wait for an array of threads to finish their processes
     * @param threads The array of threads to wait for
     */
    public static void waitForThreads(Thread[] threads) {
        try {
            for (Thread thread : threads)
                thread.join();
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        }
    }
}

Related Tutorials