the child thread interrupted, resets this thread to the interrupted state after catchException. Why is the state obtained in the last line of the code still false?
public class TheadStatusTest {
public static void main(String[] args) throws InterruptedException {
Thread s = new Thread(()->{
try {
System.out.println(Thread.currentThread().getName());
Thread.sleep(Integer.MAX_VALUE);
} catch (InterruptedException e) {
//clearfalse
// false
System.out.println("INTERRUPTED ..." + Thread.currentThread().isInterrupted());
// System.out.println("INTERRUPTED ..." + Thread.interrupted()); //
e.printStackTrace();
//
Thread.currentThread().interrupt();
// ture
System.out.println("INTERRUPTED 2 ..." + Thread.currentThread().isInterrupted());
}
}, "Abc-thread-");
s.start();
//true //
s.interrupt();
Thread.sleep(1000);
System.out.println("===>"+ s.isInterrupted()); //main.sleepfalse
}
}