[concurrency-interest] Pausing the idle threads in a pool for
minnieh at corp.earthlink.net
Mon Apr 4 20:12:27 EDT 2005
Thank you Joe!! However I had another question to the group.
Is it possible to pause/resume the idle threads in the pool? I am trying to
implement request throttling. In the process of doing so, I would like to
pause all the idle threads in the pool once the request counter reaches its
maximum to up until the request rate counter is reset. The request rate
counter is gets reset every 1 second and is supposed to allow only 4
requests to pass through.
From: Joe Bowbeer [mailto:jozart at blarg.net]
Sent: Sunday, April 03, 2005 10:46 PM
To: Minnie Haridasa; concurrency-interest at altair.cs.oswego.edu
Subject: Re: [concurrency-interest] Cancelling Tasks returning immediately..
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