Jay Roy
asked on
Thread.currentThread().interrupt();
Hi guys
public class TaskRunnable impliments Runnable{
BlockingQueue<Task> queue;
public void run(){
try{
processTask(queue));
}
catch (InterruptedException e){
Thread.currentThread().int errupt(); -- What does this do and why is this considered a good practice?
}
}
}
thanks
public class TaskRunnable impliments Runnable{
BlockingQueue<Task> queue;
public void run(){
try{
processTask(queue));
}
catch (InterruptedException e){
Thread.currentThread().int
}
}
}
thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
"If you catch InterruptedException but cannot rethrow it, you should preserve evidence that the interruption occurred so that code higher up on the call stack can learn of the interruption and respond to it if it wants to. This task is accomplished by calling interrupt() to "reinterrupt" the current thread, as shown in Listing 3."
>>>so that code higher up on the call stack can learn of the interruption and respond to it if it wants to.
what is the code higher up the author is referring to ?
how does the code higher up respond to the interruption?
A simple example would be greatly appreciated.
thanks