United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6233235 Add allowCoreThreadTimeOut to ThreadPoolExecutor to optionally allow core thread to use keep-alive
JDK-6233235 : Add allowCoreThreadTimeOut to ThreadPoolExecutor to optionally allow core thread to use keep-alive

Details
Type:
Enhancement
Submit Date:
2005-02-25
Status:
Resolved
Updated Date:
2010-04-02
Project Name:
JDK
Resolved Date:
2005-09-04
Component:
core-libs
OS:
generic
Sub-Component:
java.util.concurrent
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports
Relates:

Sub Tasks

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
                                     
2005-02-25



Hardware and Software, Engineered to Work Together