[concurrency-interest] ForkJoinPool not designed for nested Java 8 streams.parallel().forEach( ... )

Doug Lea dl at cs.oswego.edu
Tue May 6 13:43:09 EDT 2014

On 05/06/2014 11:38 AM, Christian Fries wrote:

> Thank you for the suggestion. However - I do not need any manage blocker to
> perfectly solve that performance issue. A simple workaround is the following:
> Add the method
> private void wrapInThread(Runnable runnable) ...

This does not in general do anything interesting beyond
making the task recursion stack shallower so that it becomes
less likely that nested joiners need compensation.
Which, again, is limited for resource reasons. This limit
causes your restricted parallelism. In particular, it has very
little to do with  instanceof ForkJoinWorkerThread tests.
Methods awaitJoin and externalAwaitJoin have similar implementations.
They mainly differ in that external joiners do not have guaranteed
ownership of queues.


More information about the Concurrency-interest mailing list