public class TestThread extends Thread { public void run() { System.out.println(this.getName() + "子线程开始"); try { // 子线程休眠五秒 Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println(this.getName() + "子线程结束"); } } 首先是一个线程,它执行完成需要5秒。   1、主线程等待一个子线程 public class Main { public static void main(Strin… Read More