[concurrency-interest] Best way to remove a scheduled task with ScheduledThreadPoolExecutor

Robert Bowen syg6 at yahoo.com
Tue Oct 10 15:10:52 EDT 2006

Hmmm ... I'm at home now and don't have my code in front of me but ... if I am not mistaken, when you call ScheduledThreadPoolExecutor.scheduleAtFixedRate(Runnable) what you're left with is an Executor with Future Tasks, each one an instance of your Runnable. So my question remains, how do I get access to each individual Runnable / Future Task, so I can call cancel() on it?

Maybe I'll see it more clearly when I have the code in front of me ...

Thanks for your help!

----- Original Message ----
From: Joe Bowbeer <joe.bowbeer at gmail.com>
To: concurrency-interest at cs.oswego.edu
Sent: Tuesday, October 10, 2006 6:08:39 PM
Subject: Re: [concurrency-interest] Best way to remove a scheduled task with ScheduledThreadPoolExecutor

After cancel() you *can* call STPE.purge() to remove it ASAP.  But
this is probably not necessary unless you're wasting lots and lots of

On 10/10/06, Holger Hoffstätte <holger at wizards.de> wrote:
> Robert Bowen wrote:
> > I am using a ScheduledThreadPoolExecutor to schedule Runnable tasks. I
> > would like to be able to remove tasks as well. I see in the API that
> > ScheduledThreadPoolExecutor has a remove() method which takes a Runnable
> > as a parameter. Fantastic! How do I tell it which Runnable I want to remove?
> You cannot - that method does not work as expected and contains an
> internal bug that got fixed in Mustang b71. Check the mailing list
> archives from around last December/January, there was a fairly long
> discussion about this. Summary: just use cancel() on your returned Futures
> - this will let the tasks drop out of the queue eventually.
> Holger

Concurrency-interest mailing list
Concurrency-interest at altair.cs.oswego.edu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20061010/71bbbec5/attachment.html 

More information about the Concurrency-interest mailing list