InterruptCheck.java
资源名称:Source.rar [点击查看]
上传用户:songled
上传日期:2022-07-14
资源大小:94k
文件大小:1k
源码类别:
进程与线程
开发平台:
Java
- 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());
- }
- }