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

ThreadPoolExecutor takes long time to shutdown

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Cannot Reproduce
    • Affects Version/s: 8u25
    • Fix Version/s: None
    • Component/s: core-libs
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      linux_ubuntu

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_25"
      Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
      Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux rigel 3.13.0-40-generic #69-Ubuntu SMP Thu Nov 13 17:53:56 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      HP Envy dv7 laptop as well as some other machines.

      A DESCRIPTION OF THE PROBLEM :
      A ThreadPoolExecutor instance with 5 workers and no work ever scheduled, with ThreadPoolExecutor's shutdown method followed by awaitTermination(120000L, TimeUnit.MILLISECONDS) blocks full 120000 -even when there is no processing being performed by any workers. This is unacceptable as shutdown must be immediate as no work is being performed or may be performed.

       The queue is empty and all workers are in CANCELLED state on entry to awaitTermination.

      State on entry in awaitTermination:
      java.util.concurrent.ThreadPoolExecutor@1ae23815[Shutting down, pool size = 5, active threads = 5, queued tasks = 0, completed tasks = 0]

      workers: [java.util.concurrent.ThreadPoolExecutor$Worker@5693d1d2[State = 1, empty queue], java.util.concurrent.ThreadPoolExecutor$Worker@40199d5e[State = 1, empty queue], java.util.concurrent.ThreadPoolExecutor$Worker@7533923b[State = 1, empty queue], java.util.concurrent.ThreadPoolExecutor$Worker@c6a3f47[State = 1, empty queue], java.util.concurrent.ThreadPoolExecutor$Worker@571c7572[State = 1, empty queue]]

      termination.awaitNanos(nanos) at line 1465 blocks the full duration.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) Create ThreadPoolExecutor exec with 5 workers.
      2) exec.shutdown
      3) exec.awaitTermination(120000L, TimeUnit.MILLISECONDS)
          This must return immediately - but instead blocks for full 2 minutes.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      exec.awaitTermination(120000L, TimeUnit.MILLISECONDS)
          This must return immediately - but instead blocks for full 2 minutes.
      ACTUAL -
      exec.awaitTermination(120000L, TimeUnit.MILLISECONDS)
          This must return immediately - but instead blocks for full 2 minutes.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      1) Create ThreadPoolExecutor exec with 5 workers.
      2) exec.shutdown
      3) exec.awaitTermination(120000L, TimeUnit.MILLISECONDS)
          This must return immediately - but instead blocks for full 2 minutes.
      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            Assignee:
            lpriima Lev Priima
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: