wait();改为synchronized(this) {
    wait();
}

解决方案 »

  1.   

    test2 t2=new test2();
    t2.start();test2 not only is a object, but also is a Thread.
    Yan can synchronized a object, but you can't do it for Thread.
      

  2.   

    in the class test2,public synchronized void run(){
    ............
    }
      

  3.   

    补充:
    in the class test2,public synchronized void run(){
    ............
    }如果你要notify()一个线程,那么这个线程的run()方法必须是同步的。
    synchronized