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

David Holmes dcholmes at optusnet.com.au
Wed Oct 11 05:21:00 EDT 2006


Note however, that in Java 5, there is an issue with cancel() decreasing the
number of worker threads in the pool. This is fixed in Java 6.

David Holmes
  -----Original Message-----
  From: concurrency-interest-bounces at cs.oswego.edu
[mailto:concurrency-interest-bounces at cs.oswego.edu]On Behalf Of Robert Bowen
  Sent: Wednesday, 11 October 2006 6:59 PM
  To: Joe Bowbeer; concurrency-interest at cs.oswego.edu
  Subject: Re: [concurrency-interest] Best way to remove a scheduled task
withScheduledThreadPoolExecutor


  Right you are! Problem solved! They seemed to have thought of everything
when developing this API!

  Thanks for all your help, it saved me a lot of time!

  Bob


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


  scheduleAtFixedRate returns a (Scheduled)Future instance associated
  with your Runnable.  This Future is what you cancel.

  If you want to cancel each and every one, you can shutdownNow the
  executorService.

  On 10/10/06, Robert Bowen <syg6 at yahoo.com> wrote:
  >
  > 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!
  > Bob
  >
  _______________________________________________
  Concurrency-interest mailing list
  Concurrency-interest at altair.cs.oswego.edu
  http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest




-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20061011/4b369dd3/attachment.html 


More information about the Concurrency-interest mailing list