本帖最后由 Naruto_ahu 于 2009-10-27 19:51:37 编辑

解决方案 »

  1.   

    read有可能执行不了return语句,必须考虑到这种情况并返回适当值。
      

  2.   

     public synchronized String read(){ //ERROR
            while(ready == false){
                try{
                    wait();
                }catch(InterruptedException e){}
                ready = false;
                notify();
                return message;
            }
            
        }没有返回值(String),你的这个方法的意思是只在catch到异常的时候才会return message,如果没有异常,就不会 return一个String,这显然是不对的,没有catch到异常也应该有返回值 public synchronized String read(){ //ERROR
            while(ready == false){
                try{
                    wait();
                }catch(InterruptedException e){}
                ready = false;
                notify();
                return message;
            }
             return something;
        }
      

  3.   

    对不起,我看错了应该是catch到异常的时候也应该有返回值 惭愧........
      

  4.   

    明白了, while外没有return。谢谢
      

  5.   

    捕获到异常,因为无处理继续会执行下面语句
    return message;
    同样谢谢啦