[concurrency-interest] Introducing ForkJoinPool.commonPool

Doug Lea dl at cs.oswego.edu
Tue Oct 30 10:58:22 EDT 2012

Several converging considerations led to the introduction
of a (static) commonPool available in ForkJoinPool.
The common pool always exists (but takes up only around 100bytes
if never used), and is now the default target for any
invocation of ForkJoinTask.{fork, invoke} if the caller is
not itself executing in a given pool. In other words,
ForkJoinTask methods that before threw exceptions because
the caller was not operating in a pool now succeed, using
the commonPool. (This is a spec change, but an innocuous
and desirable one -- a previously illegal use is now legal.)

Among other niceties, this means you can use ForkJoinTasks
without even knowing about class ForkJoinPool. But you
can still of course always create your own pools and
explicitly submit to them if you need isolation or custom

As indicated in the javadocs, you can set construction
parameters for the commonPool using Properties.

In addition to simplifying usage, introducing a commonPool
allows some internal optimizations (as well as a few
new support methods, for example CountedCompleter.helpComplete)
that could not be supported as well from outside of
the ForkJoinPool class.

It seems likely that bulk parallel operation support in
JDK8, Scala, etc., will change to use the commonPool.
The updated ConcurrentHashMap (JDK8 or V8) class already does so.

The updates are now in all packagings (jsr166y, jsr166e,
and JDK8 java.util.concurrent). See the usual links:

JDK8 java.util.concurrent:
     API specs: http://gee.cs.oswego.edu/dl/jsr166/dist/docs/
     jar file: http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166.jar
     Browsable CVS sources: 

     API specs: http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166edocs/
     jar file: http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166e.jar (compiled 
using Java7 javac).
     Browsable CVS sources: 

     API specs: http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/
     jar file: http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166y.jar (compiled 
using Java6 javac).
     Browsable CVS sources: 

More information about the Concurrency-interest mailing list