RFR: 8357146: ForkJoinPool:schedule(*) does not throw RejectedExecutionException when pool is shutdown

Doug Lea dl at openjdk.org
Sun May 25 10:54:54 UTC 2025


On Sat, 24 May 2025 15:57:17 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Method startDelayScheduler should trap the ISE thrown by SharedThreadContainer.start and possibly re-try termination before eventually throwing RejectedExecutionException.
>
> src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java line 3475:
> 
>> 3473:                     ds = delayScheduler = null;
>> 3474:                     unlockRunState();
>> 3475:                     tryTerminate(false, false);
> 
> This reset okay, and the schedule methods will throw REE. The change makes me wonder about the  OOME "unable to create new native thread" scenario, should the schedule methods propagate it or throw REE with the OOME as cause?

OOME (not REE) is thrown if the creation fails in the try-finally, which seems best. But if start() throws OOME (or any other Error), I see that we should do the same back-out as with ISE, but rethrow it now vs rely on the the REE in schedule(). I'll adjust accordingly.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25431#discussion_r2106162465


More information about the core-libs-dev mailing list