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

ForkJoinPool.commonPool() does not work with 1 CPU

    XMLWordPrintable

Details

    • b05
    • 17
    • b18
    • generic
    • generic
    • Verified

    Backports

      Description

        ADDITIONAL SYSTEM INFORMATION :
        $ java -version
        openjdk version "17" 2021-09-14
        OpenJDK Runtime Environment Temurin-17+35 (build 17+35)
        OpenJDK 64-Bit Server VM Temurin-17+35 (build 17+35, mixed mode, sharing)

        A DESCRIPTION OF THE PROBLEM :
        The common pool does not process any submitted tasks if the JVM was started with Runtime.getRuntime().availableProcessors() reporting 1. This can be the case when starting it in a container or by setting the -XX:ActiveProcessorCount=1 flag.

        REGRESSION : Last worked in version 16.0.2

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run the code given below with `java -XX:ActiveProcessorCount=1 ForkJoinForget`.
        "Hello World" won't be printed this way

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Tasks submitted to the common pool get executed.
        ACTUAL -
        Tasks submitted to the common pool aren't executed.

        ---------- BEGIN SOURCE ----------
        import java.util.concurrent.ForkJoinPool;

        public class ForkJoinForget {

                public static void main(String[] args) throws Exception {
                        ForkJoinPool.commonPool().submit(() -> System.out.println("Hello World"));
                        Thread.sleep(1000);
                }
        }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        One of:
        - Not using containers with 1 CPU
        - manually set the property `java.util.concurrent.ForkJoinPool.common.parallelism` to 1
        - Not using -XX:ActiveProcessorCount=1 as startup flag

        FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

                dholmes David Holmes
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: