程序员大航子 2018-12-19 00:32 采纳率: 0%
浏览 793

为什么isInterrupted()方法, 之前执行了interrupted()方法, 就不行了。

// create a thread
        InterruptThread3 thread = new InterruptThread3();
        thread.start();

        thread.interrupt();

        // check current thread ---- main
        Assert.assertTrue("当前线程在中断的状态下", !Thread.interrupted());

        // check transfer thread ---- main ---- thread-A
      **  Assert.assertTrue("指定的线程不在中断的状态下", thread.isInterrupted());**

        // interrupt current thread ---- main
        Thread.currentThread().interrupt();

        Assert.assertTrue("当前线程不在中断的状态下", Thread.interrupted()); // resetting
        Assert.assertTrue("当前线程在中断的状态下", !Thread.interrupted());

为什么被星号引住那行过不去?

  • 写回答

1条回答 默认 最新

  • 软件求生 2018-12-19 07:09
    关注

    过不去是什么意思?interrupted是是清除中断状态的,isInterrupted执行的话将返回false。

    评论

报告相同问题?