The management interface for the thread system of the Java virtual machine.
A Java virtual machine has a single instance of the implementation class of this interface. This instance implementing this interface is an MXBean that can be obtained by calling the {@link ManagementFactory#getThreadMXBean} method orfrom the {@link ManagementFactory#getPlatformMBeanServer platform MBeanServer} method.
The ObjectName for uniquely identifying the MXBean for the thread system within an MBeanServer is:
{@link ManagementFactory#THREAD_MXBEAN_NAME java.lang:type=Threading}
Thread ID
Thread ID is a positive long value returned by calling the {@link java.lang.Thread#getId} method for a thread.The thread ID is unique during its lifetime. When a thread is terminated, this thread ID may be reused.
Some methods in this interface take a thread ID or an array of thread IDs as the input parameter and return per-thread information.
Thread CPU time
A Java virtual machine implementation may support measuring the CPU time for the current thread, for any thread, or for no threads.
The {@link #isThreadCpuTimeSupported} method can be used to determineif a Java virtual machine supports measuring of the CPU time for any thread. The {@link #isCurrentThreadCpuTimeSupported} method can be used to determine if a Java virtual machine supports measuring of the CPU time for the current thread. A Java virtual machine implementation that supports CPU time measurement for any thread will also support that for the current thread.
The CPU time provided by this interface has nanosecond precision but not necessarily nanosecond accuracy.
A Java virtual machine may disable CPU time measurement by default. The {@link #isThreadCpuTimeEnabled} and {@link #setThreadCpuTimeEnabled}methods can be used to test if CPU time measurement is enabled and to enable/disable this support respectively. Enabling thread CPU measurement could be expensive in some Java virtual machine implementations.
Thread Contention Monitoring
Some Java virtual machines may support thread contention monitoring. When thread contention monitoring is enabled, the accumulated elapsed time that the thread has blocked for synchronization or waited for notification will be collected and returned in the
ThreadInfo object.
The {@link #isThreadContentionMonitoringSupported} method can be used to determine if a Java virtual machine supports thread contention monitoring. The thread contention monitoring is disabled by default. The {@link #setThreadContentionMonitoringEnabled} method can be used to enablethread contention monitoring.
Synchronization Information and Deadlock Detection
Some Java virtual machines may support monitoring of {@linkplain #isObjectMonitorUsageSupported object monitor usage} and{@linkplain #isSynchronizerUsageSupported ownable synchronizer usage}. The {@link #getThreadInfo(long[],boolean,boolean)} and {@link #dumpAllThreads} methods can be used to obtain the thread stack traceand synchronization information including which {@linkplain LockInfo
lock} a thread is blocked toacquire or waiting on and which locks the thread currently owns.
The ThreadMXBean interface provides the {@link #findMonitorDeadlockedThreads} and {@link #findDeadlockedThreads} methods to find deadlocks inthe running application.
@see
JMX Specification.
@see
Ways to Access MXBeans
@author Mandy Chung
@version 1.20, 03/08/06
@since 1.5