[concurrency-interest] The need for a default ForkJoinPool

Brian Goetz brian at briangoetz.com
Mon Aug 16 12:39:15 EDT 2010

And this is going to become a far more widespread problem as we start to put 
parallel collections in the class library, which we want to do.  It seems an 
absurd abstraction leak that before you can construct a parallel collection, 
you have to instantiate some thread-pool thingy.  (Of course, if you want more 
control, by all means make your own pool and the libraries should be able to 
use that.)

Pool pollution is a valid concern, but note that the concern doesn't go away 
just by making more threads.  If someone drops a runaway task in a pool, 
doesn't matter what pool it is -- contention for cycles just went up.

On 8/15/2010 6:30 PM, Doug Lea wrote:
> 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
> parameters.
> 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.
> -Doug
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest

More information about the Concurrency-interest mailing list