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

Java API doc needs update to specify that explicit usage of commonPool() for CompletableFuture may replace it

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8, 11, 12
    • Fix Version/s: None
    • Component/s: core-libs

      Description

      A DESCRIPTION OF THE PROBLEM :
      The documentation for `CompletableFuture` (https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html) only states:
      > All async methods without an explicit Executor argument are performed using the ForkJoinPool.commonPool() (unless it does not support a parallelism level of at least two, in which case, a new Thread is created to run each task).

      However what it does not mention is that when using the commonPool() as explicit executor, it may be replaced as well, see http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/b5c6ff776bee/src/share/classes/java/util/concurrent/CompletableFuture.java#l412

      Example:
      CompletableFuture.runAsync(
            () -> System.out.println(Thread.currentThread().getName()),
            ForkJoinPool.commonPool()
      );


        Attachments

          Activity

            People

            • Assignee:
              dl Doug Lea
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: