So you want following:
- You want the instance of task submitted as it has some info.
- You need ability to cancel the submitted task.
Modify Class definition of your submitted task to have an instance of Future in it. Now when you submit your task to ExecutorService
it will return a Future
, you can set this Future object in your submitted task object. So now you just need to retain the submitted task and you will info as well as ability to cancel task via future.