Class ExtendedThreadMXBeanImpl
- All Implemented Interfaces:
ThreadMXBean, ThreadMXBean, PlatformManagedObject, ThreadMXBean
-
Method Summary
Modifier and TypeMethodDescriptiondumpAllExtendedThreads(boolean lockedMonitors, boolean lockedSynchronizers) API method that fetches an array of ExtendedThreadInfo objects corresponding to threads in the virtual machine during the time it is invoked.dumpAllThreads(boolean lockedMonitors, boolean lockedSynchronizers) Returns the thread info for all live platform threads with stack trace and synchronization information.dumpAllThreads(boolean lockedMonitors, boolean lockedSynchronizers, int maxDepth) Returns the thread info for all live platform threads with stack trace of the specified maximum number of elements and synchronization information. ifmaxDepth == 0, no stack trace of the thread will be dumped.long[]Finds cycles of platform threads that are in deadlock waiting to acquire object monitors or ownable synchronizers.long[]Finds cycles of platform threads that are in deadlock waiting to acquire object monitors.long[]Returns the threadIDs of all live platform threads.longReturns the total CPU time for the current thread in nanoseconds.longReturns the CPU time that the current thread has executed in user mode in nanoseconds.intReturns the current number of live platform threads that are daemon threads.static ThreadMXBeanSingleton accessor method.longgetNativeThreadId(long threadId) To satisfy com.ibm.lang.management.long[]getNativeThreadIds(long[] threadIDs) To satisfy com.ibm.lang.management.ThreadMXBean.Returns anObjectNameinstance representing the object name of this platform managed object.intReturns the peak live platform thread count since the Java virtual machine started or peak was reset.longgetThreadAllocatedBytes(long threadId) Returns an approximation of the total amount of memory, in bytes, allocated in heap memory for the thread with the specified ID.long[]getThreadAllocatedBytes(long[] threadIds) Returns an approximation of the total amount of memory, in bytes, allocated in heap memory for each thread whose ID is in the input arrayids.intReturns the current number of live platform threads including both daemon and non-daemon threads.longgetThreadCpuTime(long id) Returns the total CPU time for a thread of the specified ID in nanoseconds.long[]getThreadCpuTime(long[] threadIds) Returns the total CPU time for each thread whose ID is in the input arrayidsin nanoseconds.getThreadInfo(long id) Returns the thread info for a thread of the specifiedidwith no stack trace.getThreadInfo(long[] ids) Returns the thread info for each thread whose ID is in the input arrayidswith no stack trace.getThreadInfo(long[] ids, boolean lockedMonitors, boolean lockedSynchronizers) Get together information for threads and create instances of the ThreadInfo class.getThreadInfo(long[] ids, boolean lockedMonitors, boolean lockedSynchronizers, int maxDepth) Returns the thread info for each thread whose ID is in the input arrayids, with stack trace of the specified maximum number of elements and synchronization information.getThreadInfo(long[] ids, int maxDepth) Returns the thread info for each thread whose ID is in the input arrayids, with stack trace of a specified number of stack trace elements.getThreadInfo(long id, int maxDepth) Returns a thread info for a thread of the specifiedid, with stack trace of a specified number of stack trace elements.longgetThreadUserTime(long id) Returns the CPU time that a thread of the specified ID has executed in user mode in nanoseconds.long[]getThreadUserTime(long[] threadIds) Returns the CPU time that each thread whose ID is in the input arrayidshas executed in user mode in nanoseconds.longReturns the total number of platform threads created and also started since the Java virtual machine started.booleanTests if the Java virtual machine supports CPU time measurement from a platform thread with theThreadMXBean.getCurrentThreadCpuTime()andThreadMXBean.getCurrentThreadUserTime()methods.booleanTests if the Java virtual machine supports monitoring of object monitor usage.booleanTests if the Java virtual machine supports monitoring of ownable synchronizer usage.booleanTests if thread memory allocation measurement is enabled.booleanTests if the Java virtual machine implementation supports thread memory allocation measurement.booleanTests if thread contention monitoring is enabled.booleanTests if the Java virtual machine supports thread contention monitoring.booleanTests if thread CPU time measurement is enabled.booleanTests if the Java virtual machine implementation supports CPU time measurement for any platform thread.voidResets the peak thread count to the current number of live platform threads.voidsetThreadAllocatedMemoryEnabled(boolean value) Enables or disables thread memory allocation measurement.voidsetThreadContentionMonitoringEnabled(boolean enable) Enables or disables thread contention monitoring.voidsetThreadCpuTimeEnabled(boolean enable) Enables or disables thread CPU time measurement.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods declared in interface ThreadMXBean
getNativeThreadId, getNativeThreadIdsModifier and TypeMethodDescriptionlonggetNativeThreadId(long threadId) Find the native (operating system assigned) thread identifiers corresponding to a unique TID (as returned by java/lang/Thread.getId()).long[]getNativeThreadIds(long[] threadIDs) Fetches an array of the native (operating system assigned) identifiers corresponding to unique TIDs (as returned by java/lang/Thread.getId()) specified to it.Methods declared in interface ThreadMXBean
getCurrentThreadAllocatedBytes, getTotalThreadAllocatedBytes
-
Method Details
-
getInstance
Singleton accessor method.- Returns:
- the
ExtendedThreadMXBeanImplsingleton.
-
dumpAllExtendedThreads
public ExtendedThreadInfo[] dumpAllExtendedThreads(boolean lockedMonitors, boolean lockedSynchronizers) throws InternalError, SecurityException, UnsupportedOperationException API method that fetches an array of ExtendedThreadInfo objects corresponding to threads in the virtual machine during the time it is invoked. Fetches an array of ExtendedThreadInfo objects that provide native thread identifiers along with java.lang.management.ThreadInfo object representing the thread. Consider using dumpAllExtendedThreads() in place of dumpAllThreads() as it provides additional thread identification information in an efficient manner.- Specified by:
dumpAllExtendedThreadsin interfaceThreadMXBean- Parameters:
lockedMonitors- boolean indication of whether or not information on all currently locked object monitors is to be included in the returned arraylockedSynchronizers- boolean indication of whether or not information on all currently locked ownable synchronizers is to be included in the returned array- Returns:
- Array of ExtendedThreadInfo objects.
- Throws:
InternalError- is thrown in case an error occurs while fetching thread information, typically, an internal error resulting from an inconsistency in the class library.UnsupportedOperationException- is thrown if the JVM does not support monitoring object monitor usage or ownable synchronizer usage, even as it has been specified.SecurityException
-
getThreadAllocatedBytes
public long getThreadAllocatedBytes(long threadId) Returns an approximation of the total amount of memory, in bytes, allocated in heap memory for the thread with the specified ID. The returned value is an approximation because some Java virtual machine implementations may use object allocation mechanisms that result in a delay between the time an object is allocated and the time its size is recorded.If the thread with the specified ID is a virtual thread, is not alive, or does not exist, this method returns
-1. If thread memory allocation measurement is disabled, this method returns-1. A thread is alive if it has been started and has not yet terminated.If thread memory allocation measurement is enabled after the thread has started, the Java virtual machine implementation may choose any time up to and including the time that the capability is enabled as the point where thread memory allocation measurement starts.
- Specified by:
getThreadAllocatedBytesin interfaceThreadMXBean- Parameters:
threadId- the thread ID of a thread- Returns:
- an approximation of the total memory allocated, in bytes, in
heap memory for the thread with the specified ID if the thread with the
specified ID is a platform thread, the thread is alive, and thread memory
allocation measurement is enabled;
-1otherwise. - See Also:
-
getThreadAllocatedBytes
public long[] getThreadAllocatedBytes(long[] threadIds) Returns an approximation of the total amount of memory, in bytes, allocated in heap memory for each thread whose ID is in the input arrayids. The returned values are approximations because some Java virtual machine implementations may use object allocation mechanisms that result in a delay between the time an object is allocated and the time its size is recorded.This method is equivalent to calling the
ThreadMXBean.getThreadAllocatedBytes(long)method for each thread ID in the input arrayidsand setting the returned value in the corresponding element of the returned array.- Specified by:
getThreadAllocatedBytesin interfaceThreadMXBean- Parameters:
threadIds- an array of thread IDs.- Returns:
- an array of long values, each of which is an approximation of the total memory allocated, in bytes, in heap memory for the thread whose ID is in the corresponding element of the input array of IDs.
- See Also:
-
getThreadCpuTime
public long[] getThreadCpuTime(long[] threadIds) Returns the total CPU time for each thread whose ID is in the input arrayidsin nanoseconds. The returned values are of nanoseconds precision but not necessarily nanoseconds accuracy.This method is equivalent to calling the
ThreadMXBean.getThreadCpuTime(long)method for each thread ID in the input arrayidsand setting the returned value in the corresponding element of the returned array.- Specified by:
getThreadCpuTimein interfaceThreadMXBean- Parameters:
threadIds- an array of thread IDs.- Returns:
- an array of long values, each of which is the amount of CPU
time the thread whose ID is in the corresponding element of the input
array of IDs has used, if the thread of a specified ID is a platform
thread, the thread is alive, and CPU time measurement is enabled;
-1otherwise. - See Also:
-
getThreadUserTime
public long[] getThreadUserTime(long[] threadIds) Returns the CPU time that each thread whose ID is in the input arrayidshas executed in user mode in nanoseconds. The returned values are of nanoseconds precision but not necessarily nanoseconds accuracy.This method is equivalent to calling the
ThreadMXBean.getThreadUserTime(long)method for each thread ID in the input arrayidsand setting the returned value in the corresponding element of the returned array.- Specified by:
getThreadUserTimein interfaceThreadMXBean- Parameters:
threadIds- an array of thread IDs.- Returns:
- an array of long values, each of which is the amount of user
mode CPU time the thread whose ID is in the corresponding element of
the input array of IDs has used, if the thread of a specified ID is a
platform thread, the thread is alive, and CPU time measurement is enabled;
-1otherwise. - See Also:
-
isThreadAllocatedMemorySupported
public boolean isThreadAllocatedMemorySupported()Tests if the Java virtual machine implementation supports thread memory allocation measurement.- Specified by:
isThreadAllocatedMemorySupportedin interfaceThreadMXBean- Returns:
trueif the Java virtual machine implementation supports thread memory allocation measurement;falseotherwise.
-
isThreadAllocatedMemoryEnabled
public boolean isThreadAllocatedMemoryEnabled()Tests if thread memory allocation measurement is enabled.- Specified by:
isThreadAllocatedMemoryEnabledin interfaceThreadMXBean- Returns:
trueif thread memory allocation measurement is enabled;falseotherwise.- See Also:
-
setThreadAllocatedMemoryEnabled
public void setThreadAllocatedMemoryEnabled(boolean value) Enables or disables thread memory allocation measurement. The default is platform dependent.- Specified by:
setThreadAllocatedMemoryEnabledin interfaceThreadMXBean- Parameters:
value-trueto enable;falseto disable.- See Also:
-
findMonitorDeadlockedThreads
public long[] findMonitorDeadlockedThreads()Finds cycles of platform threads that are in deadlock waiting to acquire object monitors. That is, platform threads that are blocked waiting to enter a synchronization block or waiting to reenter a synchronization block after anObject.waitcall, where each platform thread owns one monitor while trying to obtain another monitor already held by another platform thread in a cycle. Cycles that include virtual threads are not found by this method.More formally, a thread is monitor deadlocked if it is part of a cycle in the relation "is waiting for an object monitor owned by". In the simplest case, thread A is blocked waiting for a monitor owned by thread B, and thread B is blocked waiting for a monitor owned by thread A.
This method is designed for troubleshooting use, but not for synchronization control. It might be an expensive operation.
This method finds deadlocks involving only object monitors. To find deadlocks involving both object monitors and ownable synchronizers, the
findDeadlockedThreadsmethod should be used.- Specified by:
findMonitorDeadlockedThreadsin interfaceThreadMXBean- Returns:
- an array of IDs of the platform threads that are monitor
deadlocked, if any;
nullotherwise. - See Also:
-
getAllThreadIds
public long[] getAllThreadIds()Returns the threadIDs of all live platform threads. The thread IDs of virtual threads are not included. Some threads included in the returned array may have been terminated when this method returns.- Specified by:
getAllThreadIdsin interfaceThreadMXBean- Returns:
- an array of
long, each is a thread ID.
-
getCurrentThreadCpuTime
public long getCurrentThreadCpuTime()Returns the total CPU time for the current thread in nanoseconds. The returned value is of nanoseconds precision but not necessarily nanoseconds accuracy. If the implementation distinguishes between user mode time and system mode time, the returned CPU time is the amount of time that the current thread has executed in user mode or system mode.This is a convenience method for local management use and is equivalent to calling:
getThreadCpuTime(Thread.currentThread().threadId());- Specified by:
getCurrentThreadCpuTimein interfaceThreadMXBean- Returns:
- the total CPU time for the current thread if the current
thread is a platform thread and if CPU time measurement is enabled;
-1otherwise. - See Also:
-
getCurrentThreadUserTime
public long getCurrentThreadUserTime()Returns the CPU time that the current thread has executed in user mode in nanoseconds. The returned value is of nanoseconds precision but not necessarily nanoseconds accuracy.This is a convenience method for local management use and is equivalent to calling:
getThreadUserTime(Thread.currentThread().threadId());- Specified by:
getCurrentThreadUserTimein interfaceThreadMXBean- Returns:
- the user-level CPU time for the current thread if the current
thread is a platform thread and if CPU time measurement is enabled;
-1otherwise. - See Also:
-
getDaemonThreadCount
public int getDaemonThreadCount()Returns the current number of live platform threads that are daemon threads. The count does not include virtual threads.- Specified by:
getDaemonThreadCountin interfaceThreadMXBean- Returns:
- the current number of live platform threads that are daemon threads.
-
getPeakThreadCount
public int getPeakThreadCount()Returns the peak live platform thread count since the Java virtual machine started or peak was reset. The count does not include virtual threads.- Specified by:
getPeakThreadCountin interfaceThreadMXBean- Returns:
- the peak live platform thread count.
-
getThreadCount
public int getThreadCount()Returns the current number of live platform threads including both daemon and non-daemon threads. The count does not include virtual threads.- Specified by:
getThreadCountin interfaceThreadMXBean- Returns:
- the current number of live platform threads.
-
getThreadCpuTime
public long getThreadCpuTime(long id) Returns the total CPU time for a thread of the specified ID in nanoseconds. The returned value is of nanoseconds precision but not necessarily nanoseconds accuracy. If the implementation distinguishes between user mode time and system mode time, the returned CPU time is the amount of time that the thread has executed in user mode or system mode.If the thread of the specified ID is a virtual thread, is not alive or does not exist, this method returns
-1. If CPU time measurement is disabled, this method returns-1. A thread is alive if it has been started and has not yet terminated.If CPU time measurement is enabled after the thread has started, the Java virtual machine implementation may choose any time up to and including the time that the capability is enabled as the point where CPU time measurement starts.
- Specified by:
getThreadCpuTimein interfaceThreadMXBean- Parameters:
id- the thread ID of a thread- Returns:
- the total CPU time for a thread of the specified ID if the
thread of the specified ID is a platform thread, the thread is alive,
and CPU time measurement is enabled;
-1otherwise. - See Also:
-
getThreadInfo
Returns the thread info for a thread of the specifiedidwith no stack trace. This method is equivalent to calling:getThreadInfo(id, 0);This method returns a
ThreadInfoobject representing the thread information for the thread of the specified ID. The stack trace, locked monitors, and locked synchronizers in the returnedThreadInfoobject will be empty. If a thread of the given ID is a virtual thread, is not alive, or does not exist, then this method will returnnull. A thread is alive if it has been started and has not yet terminated.MBeanServer access:
The mapped type ofThreadInfoisCompositeDatawith attributes as specified in theThreadInfo.frommethod.- Specified by:
getThreadInfoin interfaceThreadMXBean- Parameters:
id- the thread ID of the thread. Must be positive.- Returns:
- a
ThreadInfoobject for the thread of the given ID with no stack trace, no locked monitor and no synchronizer info;nullif the thread of the given ID is a virtual thread, is not alive, or it does not exist.
-
getThreadInfo
Returns the thread info for each thread whose ID is in the input arrayidswith no stack trace. This method is equivalent to calling:getThreadInfo(ids, 0);This method returns an array of the
ThreadInfoobjects. The stack trace, locked monitors, and locked synchronizers in eachThreadInfoobject will be empty. If a thread of the given ID is a virtual thread, is not alive, or does not exist, the corresponding element in the returned array will containnull. A thread is alive if it has been started and has not yet terminated.MBeanServer access:
The mapped type ofThreadInfoisCompositeDatawith attributes as specified in theThreadInfo.frommethod.- Specified by:
getThreadInfoin interfaceThreadMXBean- Parameters:
ids- an array of thread IDs.- Returns:
- an array of the
ThreadInfoobjects, each containing information about a thread whose ID is in the corresponding element of the input array of IDs with no stack trace, no locked monitor and no synchronizer info.
-
getThreadInfo
Returns the thread info for each thread whose ID is in the input arrayids, with stack trace of a specified number of stack trace elements. ThemaxDepthparameter indicates the maximum number ofStackTraceElementto be retrieved from the stack trace. IfmaxDepth == Integer.MAX_VALUE, the entire stack trace of the thread will be dumped. IfmaxDepth == 0, no stack trace of the thread will be dumped. This method does not obtain the locked monitors and locked synchronizers of the threads.When the Java virtual machine has no stack trace information about a thread or
maxDepth == 0, the stack trace in theThreadInfoobject will be an empty array ofStackTraceElement.This method returns an array of the
ThreadInfoobjects, each is the thread information about the thread with the same index as in theidsarray. If a thread of the given ID is a virtual thread, is not alive, or does not exist,nullwill be set in the corresponding element in the returned array. A thread is alive if it has been started and has not yet terminated.MBeanServer access:
The mapped type ofThreadInfoisCompositeDatawith attributes as specified in theThreadInfo.frommethod.- Specified by:
getThreadInfoin interfaceThreadMXBean- Parameters:
ids- an array of thread IDsmaxDepth- the maximum number of entries in the stack trace to be dumped.Integer.MAX_VALUEcould be used to request the entire stack to be dumped.- Returns:
- an array of the
ThreadInfoobjects, each containing information about a thread whose ID is in the corresponding element of the input array of IDs with no locked monitor and synchronizer info.
-
getThreadInfo
Get together information for threads and create instances of the ThreadInfo class.Assumes that caller has already carried out error checking on the
idandmaxDeptharguments.- Specified by:
getThreadInfoin interfaceThreadMXBean- Parameters:
ids- thread idslockedMonitors- iftrueattempt to set the returnedThreadInfowith details of object monitors locked by the specified threadlockedSynchronizers- iftrueattempt to set the returnedThreadInfowith details of ownable synchronizers locked by the specified thread- Returns:
- information for threads
- See Also:
-
getThreadInfo
public ThreadInfo[] getThreadInfo(long[] ids, boolean lockedMonitors, boolean lockedSynchronizers, int maxDepth) Description copied from interface:java.lang.management.ThreadMXBeanReturns the thread info for each thread whose ID is in the input arrayids, with stack trace of the specified maximum number of elements and synchronization information. IfmaxDepth == 0, no stack trace of the thread will be dumped.This method obtains a snapshot of the thread information for each thread including:
- stack trace of the specified maximum number of elements,
- the object monitors currently locked by the thread
if
lockedMonitorsistrue, and - the
ownable synchronizers currently locked by the thread
if
lockedSynchronizersistrue.
This method returns an array of the
ThreadInfoobjects, each is the thread information about the thread with the same index as in theidsarray. If a thread of the given ID is a virtual thread, is not alive, or does not exist,nullwill be set in the corresponding element in the returned array. A thread is alive if it has been started and has not yet terminated.If a thread does not lock any object monitor or
lockedMonitorsisfalse, the returnedThreadInfoobject will have an emptyMonitorInfoarray. Similarly, if a thread does not lock any synchronizer orlockedSynchronizersisfalse, the returnedThreadInfoobject will have an emptyLockInfoarray.When both
lockedMonitorsandlockedSynchronizersparameters arefalse, it is equivalent to calling:getThreadInfo(ids, maxDepth)This method is designed for troubleshooting use, but not for synchronization control. It might be an expensive operation.
MBeanServer access:
The mapped type ofThreadInfoisCompositeDatawith attributes as specified in theThreadInfo.frommethod.- Specified by:
getThreadInfoin interfaceThreadMXBean- Parameters:
ids- an array of thread IDs.lockedMonitors- iftrue, retrieves all locked monitors.lockedSynchronizers- iftrue, retrieves all locked ownable synchronizers.maxDepth- indicates the maximum number ofStackTraceElementto be retrieved from the stack trace.- Returns:
- an array of the
ThreadInfoobjects, each containing information about a thread whose ID is in the corresponding element of the input array of IDs. - See Also:
-
getThreadInfo
Returns a thread info for a thread of the specifiedid, with stack trace of a specified number of stack trace elements. ThemaxDepthparameter indicates the maximum number ofStackTraceElementto be retrieved from the stack trace. IfmaxDepth == Integer.MAX_VALUE, the entire stack trace of the thread will be dumped. IfmaxDepth == 0, no stack trace of the thread will be dumped. This method does not obtain the locked monitors and locked synchronizers of the thread.When the Java virtual machine has no stack trace information about a thread or
maxDepth == 0, the stack trace in theThreadInfoobject will be an empty array ofStackTraceElement.If a thread of the given ID is a virtual thread, is not alive, or does not exist, this method will return
null. A thread is alive if it has been started and has not yet terminated.MBeanServer access:
The mapped type ofThreadInfoisCompositeDatawith attributes as specified in theThreadInfo.frommethod.- Specified by:
getThreadInfoin interfaceThreadMXBean- Parameters:
id- the thread ID of the thread. Must be positive.maxDepth- the maximum number of entries in the stack trace to be dumped.Integer.MAX_VALUEcould be used to request the entire stack to be dumped.- Returns:
- a
ThreadInfoof the thread of the given ID with no locked monitor and synchronizer info.nullif the thread of the given ID is a virtual thread, is not alive or it does not exist.
-
getThreadUserTime
public long getThreadUserTime(long id) Returns the CPU time that a thread of the specified ID has executed in user mode in nanoseconds. The returned value is of nanoseconds precision but not necessarily nanoseconds accuracy.If the thread of the specified ID is a virtual thread, is not alive, or does not exist, this method returns
-1. If CPU time measurement is disabled, this method returns-1. A thread is alive if it has been started and has not yet terminated.If CPU time measurement is enabled after the thread has started, the Java virtual machine implementation may choose any time up to and including the time that the capability is enabled as the point where CPU time measurement starts.
- Specified by:
getThreadUserTimein interfaceThreadMXBean- Parameters:
id- the thread ID of a thread- Returns:
- the user-level CPU time for a thread of the specified ID if the
thread of the specified ID is a platform thread, the thread is alive,
and CPU time measurement is enabled;
-1otherwise. - See Also:
-
getTotalStartedThreadCount
public long getTotalStartedThreadCount()Returns the total number of platform threads created and also started since the Java virtual machine started. The count does not include virtual threads.- Specified by:
getTotalStartedThreadCountin interfaceThreadMXBean- Returns:
- the total number of platform threads started.
-
isCurrentThreadCpuTimeSupported
public boolean isCurrentThreadCpuTimeSupported()Tests if the Java virtual machine supports CPU time measurement from a platform thread with theThreadMXBean.getCurrentThreadCpuTime()andThreadMXBean.getCurrentThreadUserTime()methods. This method returnstrueifThreadMXBean.isThreadCpuTimeSupported()returnstrue.- Specified by:
isCurrentThreadCpuTimeSupportedin interfaceThreadMXBean- Returns:
trueif the Java virtual machine supports CPU time measurement of the current platform thread;falseotherwise.
-
isThreadContentionMonitoringEnabled
public boolean isThreadContentionMonitoringEnabled()Tests if thread contention monitoring is enabled.- Specified by:
isThreadContentionMonitoringEnabledin interfaceThreadMXBean- Returns:
trueif thread contention monitoring is enabled;falseotherwise.- See Also:
-
isThreadContentionMonitoringSupported
public boolean isThreadContentionMonitoringSupported()Tests if the Java virtual machine supports thread contention monitoring.- Specified by:
isThreadContentionMonitoringSupportedin interfaceThreadMXBean- Returns:
trueif the Java virtual machine supports thread contention monitoring;falseotherwise.
-
isThreadCpuTimeEnabled
public boolean isThreadCpuTimeEnabled()Tests if thread CPU time measurement is enabled.- Specified by:
isThreadCpuTimeEnabledin interfaceThreadMXBean- Returns:
trueif thread CPU time measurement is enabled;falseotherwise.- See Also:
-
isThreadCpuTimeSupported
public boolean isThreadCpuTimeSupported()Tests if the Java virtual machine implementation supports CPU time measurement for any platform thread. A Java virtual machine implementation that supports CPU time measurement for any platform thread will also support CPU time measurement for the current thread, when the current thread is a platform thread.- Specified by:
isThreadCpuTimeSupportedin interfaceThreadMXBean- Returns:
trueif the Java virtual machine supports CPU time measurement for any platform thread;falseotherwise.
-
resetPeakThreadCount
public void resetPeakThreadCount()Resets the peak thread count to the current number of live platform threads.- Specified by:
resetPeakThreadCountin interfaceThreadMXBean- See Also:
-
setThreadContentionMonitoringEnabled
public void setThreadContentionMonitoringEnabled(boolean enable) Enables or disables thread contention monitoring. Thread contention monitoring is disabled by default.- Specified by:
setThreadContentionMonitoringEnabledin interfaceThreadMXBean- Parameters:
enable-trueto enable;falseto disable.- See Also:
-
setThreadCpuTimeEnabled
public void setThreadCpuTimeEnabled(boolean enable) Enables or disables thread CPU time measurement. The default is platform dependent.- Specified by:
setThreadCpuTimeEnabledin interfaceThreadMXBean- Parameters:
enable-trueto enable;falseto disable.- See Also:
-
isObjectMonitorUsageSupported
public boolean isObjectMonitorUsageSupported()Tests if the Java virtual machine supports monitoring of object monitor usage.- Specified by:
isObjectMonitorUsageSupportedin interfaceThreadMXBean- Returns:
trueif the Java virtual machine supports monitoring of object monitor usage;falseotherwise.- See Also:
-
isSynchronizerUsageSupported
public boolean isSynchronizerUsageSupported()Tests if the Java virtual machine supports monitoring of ownable synchronizer usage.- Specified by:
isSynchronizerUsageSupportedin interfaceThreadMXBean- Returns:
trueif the Java virtual machine supports monitoring of ownable synchronizer usage;falseotherwise.- See Also:
-
findDeadlockedThreads
public long[] findDeadlockedThreads()Finds cycles of platform threads that are in deadlock waiting to acquire object monitors or ownable synchronizers. Platform threads are deadlocked in a cycle waiting for a lock of these two types if each thread owns one lock while trying to acquire another lock already held by another platform thread in the cycle. Cycles that include virtual threads are not found by this method.This method is designed for troubleshooting use, but not for synchronization control. It might be an expensive operation.
- Specified by:
findDeadlockedThreadsin interfaceThreadMXBean- Returns:
- an array of IDs of the platform threads that are
deadlocked waiting for object monitors or ownable synchronizers, if any;
nullotherwise. - See Also:
-
dumpAllThreads
Returns the thread info for all live platform threads with stack trace and synchronization information. The thread IDs of virtual threads are not included. This method is equivalent to calling:dumpAllThreads(lockedMonitors, lockedSynchronizers, Integer.MAX_VALUE)- Specified by:
dumpAllThreadsin interfaceThreadMXBean- Parameters:
lockedMonitors- iftrue, dump all locked monitors.lockedSynchronizers- iftrue, dump all locked ownable synchronizers.- Returns:
- an array of
ThreadInfofor all live platform threads. - See Also:
-
dumpAllThreads
public ThreadInfo[] dumpAllThreads(boolean lockedMonitors, boolean lockedSynchronizers, int maxDepth) Returns the thread info for all live platform threads with stack trace of the specified maximum number of elements and synchronization information. ifmaxDepth == 0, no stack trace of the thread will be dumped. The thread IDs of virtual threads are not included. Some threads included in the returned array may have been terminated when this method returns.This method returns an array of
ThreadInfoobjects as specified in theThreadMXBean.getThreadInfo(long[], boolean, boolean, int)method.- Specified by:
dumpAllThreadsin interfaceThreadMXBean- Parameters:
lockedMonitors- iftrue, dump all locked monitors.lockedSynchronizers- iftrue, dump all locked ownable synchronizers.maxDepth- indicates the maximum number ofStackTraceElementto be retrieved from the stack trace.- Returns:
- an array of
ThreadInfofor all live platform threads. - See Also:
-
getNativeThreadIds
public long[] getNativeThreadIds(long[] threadIDs) throws IllegalArgumentException, SecurityException To satisfy com.ibm.lang.management.ThreadMXBean. -
getNativeThreadId
To satisfy com.ibm.lang.management. -
getObjectName
Returns anObjectNameinstance representing the object name of this platform managed object.- Specified by:
getObjectNamein interfacePlatformManagedObject- Returns:
- an
ObjectNameinstance representing the object name of this platform managed object.
-