I have implemented custom cancellation logic as described in Concurrency in Practice.
Encapsulating nonstandard cancellation in a task with newTaskFor.
This works fine and I can call cancel on the a future and the task is cancelled as expected. I need to be able to destroy my executor service which i am using by calling "shutdownNow" method, but this method simply calls interupt on the threads which means my custom cancel logic is never called. As my tasks use non-blocking sockets interrupting the thread does not work hence why i have custom cancellation logic.
Is there a simple solution to cancel all the tasks in progress. I have tried overwriting the shutdown method on ThreadPoolExecutor but I don't have access to the list of workers. I would like to be able to cancel everything by shutting down the executor as its used in several places to submit tasks, is there a simple solution to this?