Java tutorial
//package com.java2s; public class Main { public static void waitUntilLe(int activeThreadCount) { while (Thread.activeCount() > activeThreadCount) { try { Thread.sleep(1 * 1000); } catch (InterruptedException e) { return; } } } }