Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6233235

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

    XMLWordPrintable

Details

    • Enhancement
    • Status: Resolved
    • P4
    • Resolution: Fixed
    • 6
    • 6
    • core-libs

    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

      Attachments

        Issue Links

          Activity

            People

              martin Martin Buchholz
              martin Martin Buchholz
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: