java.lang.Thread.State
1 public class TheadStatusTest { 2 3 public static void main(String[] args) throws InterruptedException { 4 5 Thread s = new Thread(()->{ 6 try { 7 System.out.println(Thread.currentThread().getName()); 8 Thread.sleep(Integer.MAX_VALUE); 9 } catch (InterruptedException e) { 10 //抛出异常后,线程的标示位已经clear成false了 11 // 这里返回false 12 System.out.println("INTERRUPTED ..." + Thread.currentThread().isInterrupted()); 13 // System.out.println("INTERRUPTED ..." + Thread.interrupted()); 14 e.printStackTrace(); 15 16 //重新设置标示位 17 Thread.currentThread().interrupt(); 18 // 这里返回ture 19 System.out.println("INTERRUPTED 2 ..." + Thread.currentThread().isInterrupted()); 20 } 21 }, "Abc-thread-"); 22 s.start(); 23 24 //设置线程标示位为true 25 s.interrupt(); 26 Thread.sleep(100); 27 System.out.println("===>"+ s.isInterrupted()); 28 } 29 }
InterruptedException抛出之后,线程的状态为什么还是false?