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

threadGroup.enumerate() ignores the Signal Dispatcher thread

XMLWordPrintable



      Name: gm110360 Date: 05/14/2004


      FULL PRODUCT VERSION :
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-be
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      threadGroup.enumerate() does neither return a reference to the Signal Dispatcher thread nor does it include the Signal Dispatcher thread to the number of counted threads.

      If you use java.lang.management.ThreadMBean class, getThreadCount() does include the Signal Dispatcher in its count:

          ThreadMBean tb = ManagementFactory.getThreadMBean();
          Thread[] t = new Thread[500];
          ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
          while (threadGroup.getParent() != null)
          {
            threadGroup = threadGroup.getParent() ;
          }
          System.out.println(threadGroup.enumerate(t)); //ouput is '3'
          System.out.println(tb.getThreadCount()); //output is '4'



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the program given under source code with JDK 1.5 Beta 1:




      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Both outputs should be '4' and the thread-array should contain a reference to the Signal Dispatcher.
      ACTUAL -
      Output of threadGroup.enumerate() is '3'
      Output of threadMBean.getThreadCount() is '4'

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.lang.management.ManagementFactory;
      import java.lang.management.ThreadMBean;
      import java.util.*;

      public class Main
      {
        public static void main(String[] args)
        {
          ThreadMBean tb = ManagementFactory.getThreadMBean();
          Thread[] t = new Thread[500];
          ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
          while (threadGroup.getParent() != null)
          {
            threadGroup = threadGroup.getParent() ;
          }
          System.out.println(threadGroup.enumerate(t));
          System.out.println(tb.getThreadCount());
        }
      }
      ---------- END SOURCE ----------
      (Incident Review ID: 265482)
      ======================================================================

            alanb Alan Bateman
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: