I have the following code
ExecutorService es = Executors.newSingleThreadExecutor();
es.submit(new Runnable() {
@Override public void run()
isInterrupted()
returns true if and only if thread's execution is interrupted.
ExecutorService es = Executors.newSingleThreadExecutor();
es.submit(new Runnable() {
@Override public void run()
{ // infinite loop to process
while(true)
{
// We've been interrupted: no more processing.
if(Thread.currentThread().isInterrupted()){
return;
}
}
}
});
es.shutdownNow();