package cn; public class Test41 { static Thread t1 = null; static Thread t2 = null; public static void main(String[] args) { Object o = new Object(); char[] aI = "1234567".toCharArray(); char[] aS = "ABCDEFG".toCharArray(); t1 = new Thread(){ public void run(){ synchronized (o){ for(char c : aI){ System.out.println(c); try { o.notify(); o.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } o.notify(); } } }; t2 = new Thread(){ public void run(){ synchronized (o){ for(char c : aS){ System.out.println(c); try { o.notify(); o.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } o.notify(); } } }; t1.start(); t2.start(); } }