public static void main(String[] args) throws InterruptedException { CountDownLatch latch =new CountDownLatch(10); for (int i = 0; i < 900; i++) { new Thread(new Runnable() { @Override public void run() { System.out.println(Thread.currentThread().getName() ); try { Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } finally { latch.countDown(); } } }).start(); } System.out.println("等待子线程运行结束"); latch.await(); System.out.println("子线程运行结束"); }