You should not interrupt flows that you do not “own” because you do not know how they react. Since you do not control thread scheduling, you really do not know that a given thread is performing a specific task at the moment you interrupt it.
If you want to cancel the job that you provided to the executor service, call cancel(true) in the corresponding Future . When your task detects an interrupt request, it should maintain an interrupted status by calling Thread.currentThread().interrupt() .
If you do this, the worker will handle the interrupt cleanly because it interrupted the thread itself and knows that the thread was executing the task when the interrupt occurred.
erickson
source share