We all know that when catching an interruptedexception we are supposed to Thread.currentThread().interrupt();
However, from my tests, that flag is already set.
Thread t = new Thread(() -> {
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
// Thread.currentThread().interrupt();
}
});
t.start();
System.out.println(t.isInterrupted());
t.interrupt();
System.out.println(t.isInterrupted());
Prints:
false
true
So what is the point of that commented out line?