interruptcheck.java
来自「Java Thread Programming (Source」· Java 代码 · 共 19 行
JAVA
19 行
public class InterruptCheck extends Object {
public static void main(String[] args) {
Thread t = Thread.currentThread();
System.out.println("Point A: t.isInterrupted()=" + t.isInterrupted());
t.interrupt();
System.out.println("Point B: t.isInterrupted()=" + t.isInterrupted());
System.out.println("Point C: t.isInterrupted()=" + t.isInterrupted());
try {
Thread.sleep(2000);
System.out.println("was NOT interrupted");
} catch ( InterruptedException x ) {
System.out.println("was interrupted");
}
System.out.println("Point D: t.isInterrupted()=" + t.isInterrupted());
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?