[concurrency-interest] Single-threaded ForkJoinPool

Doug Lea dl at cs.oswego.edu
Sun Feb 21 15:48:28 EST 2016

Sorry for the delay...

On 02/11/2016 11:35 PM, cowwoc wrote:

> As an aside, do you plan on fixing tryAddWorker() so it retries launching a new
> thread if one is still needed?

It's a feature (not a bug) also used in ThreadPoolExecutor
to avoid infinitely looping failures (including for example
A failed (null or exceptional) call to newThread is not
retried until the next opportunity to call it.
We should clarify the documentation, as below.

Not directly relevantly, but I'm also finally getting to think
that we should add some control/tuning parameters to ForkJoinPool.
More on that soon.

      * Factory for creating new {@link ForkJoinWorkerThread}s.
      * A {@code ForkJoinWorkerThreadFactory} must be defined and used
      * for {@code ForkJoinWorkerThread} subclasses that extend base
      * functionality or initialize threads with different contexts.
     public static interface ForkJoinWorkerThreadFactory {
          * Returns a new worker thread operating in the given pool.
          * Returning null or throwing an exception may result in tasks
          * never being executed.  If this method throws an exception,
          * it is relayed to the caller of the method (for example
          * {@code execute}) causing attempted thread creation. If this
          * method returns null or throws an exception, it is not
          * retried until the next attempted creation (for example
          * another call to {@code execute}).
          * @param pool the pool this thread works in
          * @return the new worker thread, or {@code null} if the request
          *         to create a thread is rejected.
          * @throws NullPointerException if the pool is null
         public ForkJoinWorkerThread newThread(ForkJoinPool pool);

More information about the Concurrency-interest mailing list