线程的简单问题
public class Test extends Thread {
public void run() {
try {
sleep(3000);
} catch (InterruptedException e) {
System.out.println("中断");
}
System.out.println("继续执行");
}
public static void main(String[] args) {
Test t = new Test();
Thread th = new Thread(t);
th.start();
th.interrupt();
for (int i = 0; i < 1000; i++)
;
System.out.println("中止");
}
}
为什么要我调用了interrupt()这个方法后,
System.out.println("继续执行");这行代码还会打印出来呢?
是因为它我调用interrupt()后出现异常,所以异常后面的代码会执行吗?