I have found this structure popular in the multithreading chapter of Thinking in java:
public void run(){
try{
while(!Thread.currentThread().isInterrupted()){
// do something blocked like wait(), sleep() or I/O
}
}catch(InterruptedExeption e){
}
}
However I think now that the while loop will exit if and only if the blocked wait(), sleep() or I/O throws InterruptedExeption, why not use while(true) instead? Or just because the Thread.currentThread().isInterrupted() is just canonical?