0

I went through many discussion, specially Removing all queued tasks of an ThreadPoolExecutor It is a good solution but in my program I can't use storing Futures because it may require to remove tasks from the queue even after an hour or two from various places, so I want some other approach to solve it.

Can I go along with getQueue() and remove() methods, is it going to work? In description it is mention that remove() method can't remove transformed task like one which is having future then how can I remove those task? (other than storing Futures and canceling)

and one more thing in documentation it is recommended that getQueue() should not be used other than Monitoring and Debugging purpose, so how it will affects in my case. Thanks a lot for above mention discussion, I hope I will get solution for my problem.

Community
  • 1
  • 1
monu
  • 835
  • 2
  • 9
  • 14
  • How does removing a task even an hour or two stop you from storing the futures? I had a similar task, so I used a Set of Futures (and used a concurrent set or something like that). – Minas Mina Jan 06 '15 at 11:09
  • In my Program there is a TaskGenerator class which generates tasks and submits it to executor. Now there are multiple calls to TaskGenerator (ie. consider 2).So for both the calls Future object will be stored in same List (Restricted in my case) and when i want to remove tasks generated by first call, i don't know which futures belongs to first call in the list. – monu Jan 07 '15 at 10:24
  • Therefore i am thinking to store for each task where id is unique member for each task.Is it Fine? – monu Jan 07 '15 at 10:27

0 Answers0