Java tutorial
//package com.java2s; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; public class Main { public static void await(Runnable r, CountDownLatch latch, int timeout) { start(r); await(latch, timeout); } public static void await(Runnable r, CountDownLatch latch) { start(r); await(latch); } public static void await(CountDownLatch latch, int timeout) { try { latch.await(timeout, TimeUnit.SECONDS); } catch (InterruptedException e) { // Meh } } public static void await(CountDownLatch latch) { try { latch.await(); } catch (InterruptedException e) { // Meh } } public static Thread start(Runnable r) { Thread t = new Thread(r); t.start(); return t; } }