JDK-6233235 : Add allowCoreThreadTimeOut to ThreadPoolExecutor to optionally allow core thread to use keep-alive
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util.concurrent
  • Affected Version: 6
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-02-25
  • Updated: 2010-04-02
  • Resolved: 2005-09-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b51Fixed
Related Reports
Relates :  
Description
From Doug Lea:

Add allowCoreThreadTimeOut to ThreadPoolExecutor to optionally allow core thread to use keep-alive policy.

Here's the initial post that triggered this RFE:

http://altair.cs.oswego.edu/pipermail/concurrency-interest/2004-December/001247.html

I would like to use a thread pool that is 1) bounded, but 2) does NOT
keep any threads (and JVM) alive if there are no requests for
sufficiently long time (e.g. 30s). When the pool gets contended (i.e.
maximum number of used worker threads is reached), I would like it to
start enqueuing subsequent tasks rather than rejecting them. The most
intuitive approach - set core size to 0, maximum pool size to the
bounding value, and the queue to some kind of LinkedQueue or ArrayQueue
- fails: no tasks get executed at all (consistently with Javadoc but -
IMHO - a little bit counterintuitively).

Another way to look at this: I want something like fixed thread pool
(Executors.newFixedThreadPool()) but with threads dying off when they
are idle for too long, and re-created when they are needed again.

Is there a simple way to achieve this, one might think, quite reasonable
behavior?

###@###.### 2005-03-04 04:19:37 GMT

Comments
EVALUATION Being imported from 166x. ###@###.### 2005-2-25 16:48:59 GMT
25-02-2005