/** * 四个线程ABCD,分别打印A/B/C/D */ public class ABCD { public static void main(String[] args) { new PrintABCD().start(); } } class PrintABCD { private static enum PrintStatus { A, B, C, D }; private static PrintStatus nstatus; public void start() { nstatus = PrintStatus.A; Thread thread1 = new Thread(new PrintA()); Thread thread2 = new Thread(new PrintB()); Thread thread3 = new Thread(new PrintC()); Thread thread4 = new Thread(new PrintD()); thread1.start(); thread2.start(); thread3.start(); thread4.start(); } private synchronized void print(PrintStatus status) { if (nstatus == status) { // System.out.println(Thread.currentThread().getName() + " "); System.out.print(status); if (status == PrintStatus.D) { System.out.println(); } changeStatus(); return; } } private void chan