-
Sub-task
-
Resolution: Delivered
-
P4
-
22
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.
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.