<=20与<20不同的结果 public class PrintNum{ private Object lock = new Object(); public void test() { printThread p1 = new printThread("t1"); printThread p2 = new printThread("t2"); p1.start(); p2.start(); } public static void main(String[] args) { PrintNum p = new PrintNum(); p.test(); } class printThread extends Thread { public printThread(String name) { this.setName(name); } @Override public void run() { synchronized (lock) { lock.notify(); for(int i=1;i<=20;i++) { if(i%10==0) try { lock.wait(); } catch (InterruptedException e) {} System.out.println(this.getName()+" "+i); } } } } }