[code=Java][/codwhile(true) {
try{
Thread.sleep(100);
synchronized(data) {
data.update();
}
} catch(InterruptedException e) {
System.err.println("break!");
}
catch(Exception f) {
System.err.println("error!");
}
}
这段程序
当Thread.sleep(100)出现什么情况的时候抛出InterrupteException 异常啊
出现什么问题的时候 打印出 "error!" 啊
try{
Thread.sleep(100);
synchronized(data) {
data.update();
}
} catch(InterruptedException e) {
System.err.println("break!");
}
catch(Exception f) {
System.err.println("error!");
}
}
这段程序
当Thread.sleep(100)出现什么情况的时候抛出InterrupteException 异常啊
出现什么问题的时候 打印出 "error!" 啊
如果有其他线程调用它的 interrupt() 方法就会抛出InterruptedException。
而如果data.update();会抛出其它Exception ,则会打印出 "error!"