Thread.isInterrupted()第一次返回true,然后返回false?

时间:2020-03-30 05:12:22

标签: java

   public static void main(String... args){
        Thread.currentThread().interrupt();
        logger.warn("{}", Thread.currentThread().isInterrupted());//true
        logger.warn("{}", Thread.currentThread().isInterrupted());//false
}

结果显示:isInterrupted()的第一次调用返回trueisInterrupted()的第二次调用返回false,我读到Thread.isInterrupted()的DOC时说:{{ 1}}

因此,为什么Tests whether this thread has been interrupted. The <i>interrupted status</i> of the thread is unaffected by this method.的第二次调用和后续调用都返回false,无论根据DOC调用了多少次isInterrupted(),它都应该始终返回true。

0 个答案:

没有答案
相关问题