[concurrency-interest] The need for a default ForkJoinPool

Doug Lea dl at cs.oswego.edu
Sun Aug 15 18:30:14 EDT 2010

On 08/15/10 07:38, Kasper Nielsen wrote:
> Hi,
> Having used the FJ classes for a couple of libraries. The one thing that is
> really annoying me is the fact that there are no default ForkJoinPool I can use.

I think this will become a common concern. I'm not sure what
the best solution is though. In most ways, it makes sense
to have exactly one pool per program constructed with default
target parallelism (i.e., equal to #CPUs/cores). If you have
more than one, then they will eat up unnecessary resources
and will contend with each other. It also can make sense to
to occasionally use others with lower parallelism or different

On the other hand, some methods (like shutdown) on a single global
pool could not be made accessible.

Also, as implied by Tim, having a single global pool invites
surprise and unhappiness when unknown other parts of a system
are abusing it -- for example running tasks that never terminate
or lock themselves up.

It might be reasonable to compromise along the lines you suggest
-- to have a default one (that we would need to support by somehow
disabling shutdown etc), so that people at least knowingly expose
themselves to the risks.

Other suggestions welcome.


More information about the Concurrency-interest mailing list