按照jdk的说明没有notify()或notifyAll(),wait()不会醒过来的,关注一下~~知道的说明一下哦

解决方案 »

  1.   

    试一下public class Test_thread {
               private class T extends Thread {
    public void run() {

    try {
    System.out.println("before!");
                 this.wait();
    System.out.println("after!"); } catch (Exception e) {System.out.println("exception!"); e.printStackTrace(System.out);}  System.out.println("morning!"); }
     }

             public Test_thread(){
    T t =new T();
    t.start();
    }          public static void main(String[] args) {
    Test_thread t1 = new Test_thread();
    try
    {
    Thread.sleep(2000);
    }
    catch(Exception ex) {}
    }}
      

  2.   

    你那个 wait() 根本没有被执行, 有异常被抛出~~ 被捕获以后程序继续执行你在catch 后面把异常打印出来就清楚了
      

  3.   

    任何调用wait和notify(notifyAll)的线程都要获得相应的对象的锁其标。
    也就是的在sychronized里面。
    public class Test_thread {
               private class T extends Thread {
    public synchronized void run() {

    try {              this.wait(); } catch (Exception e) { }
     System.out.println("morning!");
    }
     }

             public Test_thread(){
    T t=new T();
    t.start();
    }          public static void main(String[] args) {
    Test_thread t1 = new Test_thread();
    }}