Code example for CountDownLatch

Methods: await

0
    /** 
     * @param args 
     */ 
    public static void main(String[] args) {
        int size = 3;
        CountDownLatch latch = new CountDownLatch(size);
 
        new Worker("worker1", 11000, latch).start();
        new Worker("worker2", 20000, latch).start();
        new Worker("worker3", 10400, latch).start();
 
        try { 
            latch.await();
        } catch (InterruptedException e) { // TODO Auto-generated catch block
            e.printStackTrace();
        } 
 
        System.err.println("ALL WORK FINISHED");
 
    }