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 ByManagementFactory.getThreadMXBean( ) |