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

ScheduledExecutorService never executes Runnable with corePoolSize of zero

XMLWordPrintable

    • 7
    • b08
    • x86
    • linux_ubuntu
    • Verified

        FULL PRODUCT VERSION :
        Test case exhibits bug on:
        Linux dt-000839 2.6.35-30-generic #56-Ubuntu SMP Mon Jul 11 20:01:08 UTC 2011 x86_64 GNU/Linux
        Java(TM) SE Runtime Environment (build 1.7.0-b147)
        Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)

        and

        Linux wilf 2.6.38-11-generic #48-Ubuntu SMP Fri Jul 29 19:02:55 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
        OpenJDK Runtime Environment (IcedTea6 1.10.2) (6b22-1.10.2-0ubuntu1~11.04.1)
        OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)

        Test case does *not* exhibit bug on:
        Linux wilf 2.6.38-11-generic #48-Ubuntu SMP Fri Jul 29 19:02:55 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
        Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
        Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        See comments in Runtime version


        A DESCRIPTION OF THE PROBLEM :
        A Runnable submitted to a ScheduledExecutorService having a core pool size of zero is never executed.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run the attached test case

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        "Hello" is printed to stdout
        ACTUAL -
        The Runnable is never executed

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.util.concurrent.Executors;
        import java.util.concurrent.ScheduledExecutorService;
        import java.util.concurrent.TimeUnit;

        class ScheduledExecutorTest {
            public static void main(String[] args) throws InterruptedException {
                final ScheduledExecutorService ex = Executors.newScheduledThreadPool(0);
                ex.schedule(new Runnable() {
                    @Override
                    public void run() {
                        System.out.println("hello");
                    }
                }, 1, TimeUnit.SECONDS);

                ex.shutdown();
                ex.awaitTermination(5, TimeUnit.SECONDS);
            }
        }

        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Increase the corePoolSize to a value greater than zero.

              chegar Chris Hegarty
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: