[concurrency-interest] Cancelling Tasks returning immediately..

Joe Bowbeer jozart at blarg.net
Mon Apr 4 01:45:31 EDT 2005

Here's a simple approach:

When you submit your FutureTask to the executor service, also schedule a 
TimerTask to cancel that task.

If your FutureTask needs to act at the moment it is cancelled, override the 
"done" method and perform the desired action if isCancelled returns true.

----- Original Message ----- 
From: "Minnie Haridasa" <minnieh at corp.earthlink.net>
To: <concurrency-interest at altair.cs.oswego.edu>
Sent: Sunday, April 03, 2005 9:51 PM
Subject: [concurrency-interest] Cancelling Tasks returning immediately..


We have unique situation where I thought I may seek you help for some useful

My thread pool has an unbounded queue associated to it. However, while a
task is waiting on the queue to be

Processed, it cannot wait indefinitely, after a certain period of time, it
needs to cancel out and return a different result.

Is it possible to achieve this using the concurrent utilities of JDK1.5.

My queue has to be unbounded, and the task (callable) that gets put on the
queue needs to be time bound. How can I make the cancelled task return
immediately as opposed to the result that can only be retrieved using method
get when the computation has completed or the task gets its turn to be
executed by the pool.

Appreciate your help.



More information about the Concurrency-interest mailing list