While reading through someone else's code, I came across the following:
class Worker extends Thread {
....
public void run() {
try {
while ( true ) {
..... DO WORK .....
}
} catch ( InterruptedException e ) {
Thread.currentThread().interrupt();
} catch ( RuntimeException e ) {
handleFatal( e );
}
}
}
What is the effect of calling Thread.currentThread().interrupt()
inside the catch block?
Surely the current running thread - this instance of Worker
- is already interrupted at this point? What purpose does it serve to call interrupt()
again on an already interrupted thread?