Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8246587

ForkJoin updates

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Withdrawn
    • Icon: P3 P3
    • None
    • core-libs
    • None
    • source
    • minimal
    • Negligible risk of a name-clash with user ForkJoinTask subclasses
    • Java API
    • JDK

      Summary

      Add cancel-on-interrupt ForkJoinTask adaptor

      Problem

      Some potential FJ usages require that tasks are cancelled when their threads are interrupted, which is not the default policy for adapting Callables.

      Solution

      Introduce a method adaptInterruptible that supports this policy. An overview of the solution. Alternative solutions may be discussed;

      Specification

      /**
       * Returns a new {@code ForkJoinTask} that performs the {@code call}
       * method of the given {@code Callable} as its action, and returns
       * its result upon {@link #join}, translating any checked exceptions
       * encountered into {@code RuntimeException}.  Additionally,
       * invocations of {@code cancel} with {@code mayInterruptIfRunning
       * true} will attempt to interrupt the thread performing the task.
       *
       * @param callable the callable action
       * @param <T> the type of the callable's result
       * @return the task
       *
       * @since 15
       */
      public static <T> ForkJoinTask<T> adaptInterruptible(Callable<? extends T> callable)

            martin Martin Buchholz
            dl Doug Lea
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: