JDK-8318145 : Release Note: Changes to `java.util.concurrent.ForkJoinPool` and `ForkJoinTask`
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: java.util.concurrent
  • Affected Version: 22
  • Priority: P4
  • Status: Resolved
  • Resolution: Delivered
  • Submitted: 2023-10-16
  • Updated: 2024-02-14
  • Resolved: 2024-01-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 22
22Resolved
Description
A new method, `invokeAllUninterruptibly(Collection)`, is added to `java.util.concurrent.ForkJoinPool` as an uninterruptible version of `invokeAll(Collection)`.

The pre-existing `invokeAll(Collection)` method is defined by `ExecutorService` to throw `InterruptedException`.  The override of this method in `ForkJoinPool` did not declare `InterruptedException`. As part of the changes, the override of this method has been removed from `ForkJoinPool`. Existing code that is compiled to use `ForkJoinPool.invokeAll` will no longer compile without change. Code that does not wish to handle interruption can be changed to use `invokeAllUninterruptibly`.

New methods `adaptInterruptible(Runnable)` and `adaptInterruptible(Runnable, Object)` are added to `java.util.concurrent.ForkJoinTask` to support adaptation of runnable tasks that may handle interruption.

As part of the changes in this release, the `Future` objects returned by the `ForkJoinPool.submit(Runnable)` and `ForkJoinPool.submit(Callable)` are changed to align with other implementations of `ExecutorService`. More specifically:
- `Future.cancel(true)` will interrupt the thread running the task if cancelled before the task has completed.
- `Future.get` will throw `ExecutionException` with the exception as the cause  if the task fails. Previous behavior was to throw `ExecutionException` with a `RuntimeException` as the cause.