public?class?Test?extends?Thread{
public?void?run()??{
Thread.sleep(1000);
}
public?static?void?main(String[]?args)?{
new?Test().start();
}
}既然上面代碼直接調(diào)用一定會(huì)拋異常;public?class?Test?extends?Thread{
public?void?run()??{
try?{
Thread.sleep(1000);
}?catch?(InterruptedException?e)?{
e.printStackTrace();
}
}
public?static?void?main(String[]?args)?{
new?Test().start();
}
}那么加上try-catch之后catch語(yǔ)句塊為何又沒(méi)有被執(zhí)行????Thread.sleep(1000);不是必然拋異常嗎?
添加回答
舉報(bào)
0/150
提交
取消