import java.util.concurrent.*; class JoinP { public static void main(String[] args) { int numberofthreads = 10; Thread[] t = new Thread[numberofthreads]; for (int j = 0; j < numberofthreads; j++) { (t[j] = new Thread( new ExThread() )).start(); } try { for (int k = 0; k < numberofthreads; k++) t[k].join(); } catch (Exception e) { return; } } static class ExThread implements Runnable { public void run() { try { TimeUnit.SECONDS.sleep(10); } catch (Exception e) { return;}; } } }