- 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.static ThreadMXBean
Singleton accessor method.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.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
.long[]
getThreadCpuTime
(long[] threadIds) Returns the total CPU time for each thread whose ID is in the input arrayids
in nanoseconds.long[]
getThreadUserTime
(long[] threadIds) Returns the CPU time that each thread whose ID is in the input arrayids
has executed in user mode in nanoseconds.boolean
Tests if thread memory allocation measurement is enabled.boolean
Tests if the Java virtual machine implementation supports thread memory allocation measurement.void
setThreadAllocatedMemoryEnabled
(boolean value) Enables or disables thread memory allocation measurement.Methods declared in class com.ibm.java.lang.management.internal.ThreadMXBeanImpl
dumpAllThreads, dumpAllThreads, findDeadlockedThreads, findMonitorDeadlockedThreads, getAllThreadIds, getCurrentThreadCpuTime, getCurrentThreadUserTime, getDaemonThreadCount, getNativeThreadId, getNativeThreadIds, getObjectName, getPeakThreadCount, getThreadCount, getThreadCpuTime, getThreadInfo, getThreadInfo, getThreadInfo, getThreadInfo, getThreadInfo, getThreadInfo, getThreadUserTime, getTotalStartedThreadCount, isCurrentThreadCpuTimeSupported, isObjectMonitorUsageSupported, isSynchronizerUsageSupported, isThreadContentionMonitoringEnabled, isThreadContentionMonitoringSupported, isThreadCpuTimeEnabled, isThreadCpuTimeSupported, resetPeakThreadCount, setThreadContentionMonitoringEnabled, setThreadCpuTimeEnabled
Methods declared in class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods declared in interface java.lang.management.PlatformManagedObject
getObjectName
Methods declared in interface com.ibm.lang.management.ThreadMXBean
getNativeThreadId, getNativeThreadIds
Methods declared in interface com.sun.management.ThreadMXBean
getCurrentThreadAllocatedBytes, getTotalThreadAllocatedBytes
Methods declared in interface java.lang.management.ThreadMXBean
dumpAllThreads, dumpAllThreads, findDeadlockedThreads, findMonitorDeadlockedThreads, getAllThreadIds, getCurrentThreadCpuTime, getCurrentThreadUserTime, getDaemonThreadCount, getPeakThreadCount, getThreadCount, getThreadCpuTime, getThreadInfo, getThreadInfo, getThreadInfo, getThreadInfo, getThreadInfo, getThreadInfo, getThreadUserTime, getTotalStartedThreadCount, isCurrentThreadCpuTimeSupported, isObjectMonitorUsageSupported, isSynchronizerUsageSupported, isThreadContentionMonitoringEnabled, isThreadContentionMonitoringSupported, isThreadCpuTimeEnabled, isThreadCpuTimeSupported, resetPeakThreadCount, setThreadContentionMonitoringEnabled, setThreadCpuTimeEnabled
-
Method Details
-
getInstance
Singleton accessor method.- Returns:
- the
ExtendedThreadMXBeanImpl
singleton.
-
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:
dumpAllExtendedThreads
in 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.SecurityException
- is thrown if the caller does not have sufficient permissions (ManagementPermission("monitor"))UnsupportedOperationException
- is thrown if the JVM does not support monitoring object monitor usage or ownable synchronizer usage, even as it has been specified.
-
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:
getThreadAllocatedBytes
in 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;
-1
otherwise. - 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 arrayids
and setting the returned value in the corresponding element of the returned array.- Specified by:
getThreadAllocatedBytes
in 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 arrayids
in 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 arrayids
and setting the returned value in the corresponding element of the returned array.- Specified by:
getThreadCpuTime
in 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;
-1
otherwise. - See Also:
-
getThreadUserTime
public long[] getThreadUserTime(long[] threadIds) Returns the CPU time that each thread whose ID is in the input arrayids
has 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 arrayids
and setting the returned value in the corresponding element of the returned array.- Specified by:
getThreadUserTime
in 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;
-1
otherwise. - See Also:
-
isThreadAllocatedMemorySupported
public boolean isThreadAllocatedMemorySupported()Tests if the Java virtual machine implementation supports thread memory allocation measurement.- Specified by:
isThreadAllocatedMemorySupported
in interfaceThreadMXBean
- Returns:
true
if the Java virtual machine implementation supports thread memory allocation measurement;false
otherwise.
-
isThreadAllocatedMemoryEnabled
public boolean isThreadAllocatedMemoryEnabled()Tests if thread memory allocation measurement is enabled.- Specified by:
isThreadAllocatedMemoryEnabled
in interfaceThreadMXBean
- Returns:
true
if thread memory allocation measurement is enabled;false
otherwise.- See Also:
-
setThreadAllocatedMemoryEnabled
public void setThreadAllocatedMemoryEnabled(boolean value) Enables or disables thread memory allocation measurement. The default is platform dependent.- Specified by:
setThreadAllocatedMemoryEnabled
in interfaceThreadMXBean
- Parameters:
value
-true
to enable;false
to disable.- See Also:
-