关于run方法的异常的抛出

public void run() {
    while (true) {

        //此处的list 抛不出来的原因 是 因为 重写的run方法 本身没有抛出
        //这就要求重写她的方法的方法不能抛出比起更大的范围或者更抽象的范围
        synchronized (list){
            if(list.size()==0){
                try {
                    list.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            list.remove(0);
        }
    }
}

猜你喜欢

转载自blog.csdn.net/qq_34627002/article/details/88887559