public class thread5{
public static void main(String[] args){
compute t=new compute();
t.start();
t.interrupt();
}
}
class compute extends Thread{
//int i=0;
public void run(){
System.out.println("1");
try{
sleep(10000);
} catch (Exception e){
System.out.println("2");
}
}
}
以上程序本意是要输出1后休眠10秒后输出2,可是运行后,程序直接输出1和2,根本没有休眠就被唤醒输出了,这是为何呢?