ThreadMXBean


ThreadMXBean java.lang.management

Java 5.0

This MXBean interface allows monitoring of thread usage in a Java VM. A number of methods , such as getThreadCount( ) and getPeakThreadCount( ) , return information about all running threads. Other methods return information about individual threads. Threads are identified by their thread id, which is a long integer. getAllThreadIds( ) returns all ids as an array of long . Complete information, including stack trace, about a thread or set of threads can be obtained with the getTHReadInfo( ) methods, which return ThreadInfo objects.

If isThreadCpuTimeSupported( ) returns TRue , you can enable thread timing with setThreadCpuTimeEnabled( ) and query the runtime of a specific thread with getThreadCpuTime( ) and getThreadUserTime( ) . The values returned by these methods are measured in nanoseconds.

One of the potentially most useful methods of this interface is findMonitorDeadlockedThreads( ) . It looks for cycles of threads that are deadlocked waiting to lock objects whose locks are held by other threads in the cycle.

 public interface  ThreadMXBean  {  // Public Instance Methods  long[ ]  findMonitorDeadlockedThreads  ( );        long[ ]  getAllThreadIds  ( );        long  getCurrentThreadCpuTime  ( );        long  getCurrentThreadUserTime  ( );        int  getDaemonThreadCount  ( );        int  getPeakThreadCount  ( );        int  getThreadCount  ( );        long  getThreadCpuTime  (long  id  );        ThreadInfo  getThreadInfo  (long  id  );        ThreadInfo[ ]  getThreadInfo  (long[ ]  ids  );        ThreadInfo[ ]  getThreadInfo  (long[ ]  ids  , int  maxDepth  );        ThreadInfo  getThreadInfo  (long  id  , int  maxDepth  );        long  getThreadUserTime  (long  id  );        long  getTotalStartedThreadCount  ( );        boolean  isCurrentThreadCpuTimeSupported  ( );        boolean  isThreadContentionMonitoringEnabled  ( );        boolean  isThreadContentionMonitoringSupported  ( );        boolean  isThreadCpuTimeEnabled  ( );        boolean  isThreadCpuTimeSupported  ( );        void  resetPeakThreadCount  ( );        void  setThreadContentionMonitoringEnabled  (boolean  enable  );        void  setThreadCpuTimeEnabled  (boolean  enable  );   } 

Returned By

ManagementFactory.getThreadMXBean( )



Java In A Nutshell
Java In A Nutshell, 5th Edition
ISBN: 0596007736
EAN: 2147483647
Year: 2004
Pages: 1220

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net