com.ibm.lang.management
Class ThreadMXBeanImpl
- java.lang.Object
com.ibm.lang.management.DynamicMXBeanImpl
com.ibm.lang.management.ThreadMXBeanImpl
- public final class ThreadMXBeanImpl
- extends DynamicMXBeanImpl
- implements java.lang.management.ThreadMXBean
ThreadMXBean
Field Summary
| Fields inherited from class com.ibm.lang.management.DynamicMXBeanImpl |
|---|
info |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
|
dumpAllThreads(boolean lockedMonitors,boolean lockedSynchronizers)
|
|
findDeadlockedThreads()
|
|
findMonitorDeadlockedThreads()
|
|
getAllThreadIds()
|
|
getCurrentThreadCpuTime()
|
|
getCurrentThreadUserTime()
|
|
getDaemonThreadCount()
|
|
getPeakThreadCount()
|
|
getThreadCount()
|
|
getThreadCpuTime(long id)
|
|
getThreadInfo(long id)
|
|
getThreadInfo(long[] ids)
|
|
getThreadInfo(long[] ids,boolean lockedMonitors,boolean lockedSynchronizers)
Get together information for threads and create instances of the
ThreadInfo class.
|
|
getThreadInfo(long[] ids,int maxDepth)
|
|
getThreadInfo(long id,int maxDepth)
|
|
getThreadUserTime(long id)
|
|
getTotalStartedThreadCount()
|
|
isCurrentThreadCpuTimeSupported()
|
|
isObjectMonitorUsageSupported()
|
|
isSynchronizerUsageSupported()
|
|
isThreadContentionMonitoringEnabled()
|
|
isThreadContentionMonitoringSupported()
|
|
isThreadCpuTimeEnabled()
|
|
isThreadCpuTimeSupported()
|
|
resetPeakThreadCount()
|
|
setThreadContentionMonitoringEnabled(boolean enable)
|
|
setThreadCpuTimeEnabled(boolean enable)
|
| Methods inherited from class com.ibm.lang.management.DynamicMXBeanImpl |
|---|
getAttribute, getAttributes, getMBeanInfo, getPresentAttribute, getPresentOperation, initMBeanInfo, invoke, setAttribute, setAttributes, setMBeanInfo |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail
findMonitorDeadlockedThreads
- public long[] findMonitorDeadlockedThreads( )
ThreadMXBean.findDeadlockedThreads() method.
It is recommended that this method be used solely for problem determination analysis and not as a means of managing thread synchronization in a virtual machine. This is because the method may be very expensive to run.
findMonitorDeadlockedThreads in interface java.lang.management.ThreadMXBean
null if
there are currently no threads in that category. getAllThreadIds
- public long[] getAllThreadIds()
java.lang.management.ThreadMXBean
getAllThreadIds in interface java.lang.management.ThreadMXBean
getCurrentThreadCpuTime
- public long getCurrentThreadCpuTime( )
java.lang.management.ThreadMXBean
Method ThreadMXBean.isCurrentThreadCpuTimeSupported()may be used to
determine if current thread CPU timing is supported on the virtual
machine. On virtual machines where current thread CPU timing is
supported, the method ThreadMXBean.isThreadCpuTimeEnabled()may be used to
determine if thread CPU timing is actually enabled.
The return value is identical to that which would be obtained by calling
ThreadMXBean.getThreadCpuTime(long)with an argument
Thread.currentThread().getId()).
getCurrentThreadCpuTime in interface java.lang.management.ThreadMXBean
-1. getCurrentThreadUserTime
- public long getCurrentThreadUserTime( )
java.lang.management.ThreadMXBean
Method ThreadMXBean.isCurrentThreadCpuTimeSupported()may be used to
determine if current thread CPU timing is supported on the virtual
machine. On virtual machines where current thread CPU timing is
supported, the method ThreadMXBean.isThreadCpuTimeEnabled()may be used to
determine if thread CPU timing is actually enabled.
The return value is identical to that which would be obtained by calling
ThreadMXBean.getThreadUserTime(long)with an argument
Thread.currentThread().getId()).
getCurrentThreadUserTime in interface java.lang.management.ThreadMXBean
-1. getDaemonThreadCount
- public int getDaemonThreadCount( )
java.lang.management.ThreadMXBean
getDaemonThreadCount in interface java.lang.management.ThreadMXBean
getPeakThreadCount
- public int getPeakThreadCount()
java.lang.management.ThreadMXBean
getPeakThreadCount in interface java.lang.management.ThreadMXBean
ThreadMXBean.resetPeakThreadCount()getThreadCount
- public int getThreadCount()
java.lang.management.ThreadMXBean
getThreadCount in interface java.lang.management.ThreadMXBean
getThreadCpuTime
- public long getThreadCpuTime(long id)
java.lang.management.ThreadMXBean
Method ThreadMXBean.isThreadCpuTimeSupported()may be used to determine if
the CPU timing of threads is supported on the virtual machine. On virtual
machines where current thread CPU timing is supported, the method
ThreadMXBean.isThreadCpuTimeEnabled()may be used to determine if thread CPU
timing is actually enabled.
getThreadCpuTime in interface java.lang.management.ThreadMXBean
id - the identifier for a thread. Must be a positive number greater
than zero. id, the number of nanoseconds CPU time used by
the thread. On virtual machines where thread CPU timing is
supported but not enabled, or where there is no living thread
with identifier id present in the virtual machine,
a value of -1 is returned. ThreadMXBean.isThreadCpuTimeSupported(),
ThreadMXBean.isThreadCpuTimeEnabled()getThreadInfo
- public java.lang.management.ThreadInfo getThreadInfo( long id)
java.lang.management.ThreadMXBean
ThreadInfoobject for the thread with the specified
identifier. The returned object will not have a stack trace so that a
call to its getStackTrace() method will result in an empty
StackTraceElement array. Similarly, the returned object
will hold no details of locked synchronizers or locked object monitors
for the specified thread; calls to getLockedMonitors() and
getLockedSynchronizers will both return array values.
getThreadInfo in interface java.lang.management.ThreadMXBean
id - the identifier for a thread. Must be a positive number greater
than zero. id maps to a living thread in the
virtual machine (i.e. a started thread which has not yet died),
this method returns a ThreadInfoobject corresponding to
that thread. Otherwise, returns null. getThreadInfo
- public java.lang.management.ThreadInfo[] getThreadInfo( long[] ids)
java.lang.management.ThreadMXBean
ThreadInfoobjects ; one for each of the
threads specified in the input array of identifiers. None of the objects
in the return array will have a stack trace so that a call to its
getStackTrace() method will result in an empty
StackTraceElement array. Similarly, the returned object
will hold no details of locked synchronizers or locked object monitors
for the specified thread; calls to getLockedMonitors() and
getLockedSynchronizers will both return array values.
getThreadInfo in interface java.lang.management.ThreadMXBean
ids - an array of thread identifiers. Each one must be a positive
number greater than zero. ThreadInfoobjects with each entry
corresponding to one of the threads specified in the input array
of identifiers. The return array will therefore have an identical
number of elements to the input ids array. If an
entry in the ids array is invalid (there is no
living thread with the supplied identifier in the virtual
machine) then the corresponding entry in the return array will be
a null. getThreadInfo
- public java.lang.management.ThreadInfo[] getThreadInfo( long[] ids,
- int maxDepth)
java.lang.management.ThreadMXBean
ThreadInfoobjects ; one for each of the
threads specified in the ids argument. The stack trace
information in the returned objects will depend on the value of the
maxDepth argument which specifies the maximum number of
StackTraceElementinstances to try and include. A subsequent call
to any of the returned objects' getStackTrace() method
should result in a StackTraceElementarray of up to
maxDepth elements. A maxDepth value of
Integer.MAX_VALUE will attempt to obtain all of the stack
trace information for each specified thread while a maxDepth
value of zero will yield none.
The returned object will hold no details of locked synchronizers or
locked object monitors for the specified thread; calls to
getLockedMonitors() and
getLockedSynchronizers will both return array values.
getThreadInfo in interface java.lang.management.ThreadMXBean
ids - an array of thread identifiers. Each must be a positive number
greater than zero. maxDepth - the maximum number of stack trace entries to be
included in each of the returned ThreadInfo
objects. Supplying Integer.MAX_VALUE attempts
to obtain all of the stack traces. Only a positive value is
expected. ThreadInfo objects. The size of the
array will be identical to that of the ids
argument. Null elements will be placed in the array if the
corresponding thread identifier in ids does not
resolve to a living thread in the virtual machine (i.e. a started
thread which has not yet died). getThreadInfo
- public java.lang.management.ThreadInfo[] getThreadInfo( long[] ids,
- boolean lockedMonitors,
- boolean lockedSynchronizers)
Assumes that caller has already carried out error checking on the
id and maxDepth arguments.
getThreadInfo in interface java.lang.management.ThreadMXBean
ids - thread ids lockedMonitors - if true attempt to set the returned
ThreadInfo with details of object monitors
locked by the specified thread lockedSynchronizers - if true attempt to set the returned
ThreadInfo with details of ownable
synchronizers locked by the specified thread getThreadInfo
- public java.lang.management.ThreadInfo getThreadInfo( long id,
- int maxDepth)
java.lang.management.ThreadMXBean
ThreadInfoobject for the thread with the specified
identifier. The stack trace information in the returned object will
depend on the value of the maxDepth argument which
specifies the maximum number of StackTraceElementinstances to
include. A subsequent call to the returned object's
getStackTrace() method should then result in a
StackTraceElementarray of up to maxDepth
elements. A maxDepth value of
Integer.MAX_VALUE will obtain all of the stack trace
information for the thread while a maxDepth value of zero
will yield none.
It is possible that the virtual machine may be unable to supply any stack
trace information for the specified thread. In that case the returned
ThreadInfo object will have an empty array of
StackTraceElements.
The returned object will hold no details of locked synchronizers or
locked object monitors for the specified thread; calls to
getLockedMonitors() and
getLockedSynchronizers will both return array values.
getThreadInfo in interface java.lang.management.ThreadMXBean
id - the identifier for a thread. Must be a positive number greater
than zero. maxDepth - the maximum number of stack trace entries to be
included in the returned ThreadInfo object.
Supplying Integer.MAX_VALUE obtains all of the
stack trace. Only a positive value is expected. id maps to a living thread in the
virtual machine (i.e. a started thread which has not yet died),
this method returns a ThreadInfoobject corresponding to
that thread. Otherwise, returns null. getThreadUserTime
- public long getThreadUserTime(long id)
java.lang.management.ThreadMXBean
Method ThreadMXBean.isThreadCpuTimeSupported()may be used to determine if
the CPU timing of threads is supported on the virtual machine. On virtual
machines where current thread CPU timing is supported, the method
ThreadMXBean.isThreadCpuTimeEnabled()may be used to determine if thread CPU
timing is actually enabled.
getThreadUserTime in interface java.lang.management.ThreadMXBean
id - the identifier for a thread. Must be a positive number greater
than zero. id, the number of nanoseconds CPU time used by
the thread running in user mode. On virtual machines where thread
CPU timing is supported but not enabled, or where there is no
living thread with identifier id present in the
virtual machine, a value of -1 is returned.
If thread CPU timing was disabled when the thread was started
then the virtual machine is free to choose any measurement start
time between when the virtual machine started up and when thread
CPU timing was enabled with a call to
ThreadMXBean.setThreadCpuTimeEnabled(boolean).
ThreadMXBean.isThreadCpuTimeSupported(),
ThreadMXBean.isThreadCpuTimeEnabled()getTotalStartedThreadCount
- public long getTotalStartedThreadCount( )
java.lang.management.ThreadMXBean
getTotalStartedThreadCount in interface java.lang.management.ThreadMXBean
isCurrentThreadCpuTimeSupported
- public boolean isCurrentThreadCpuTimeSupported( )
java.lang.management.ThreadMXBean
Note that this method must return true if
ThreadMXBean.isThreadCpuTimeSupported()returns true.
isCurrentThreadCpuTimeSupported in interface java.lang.management.ThreadMXBean
true if CPU timing of the current thread is
supported, otherwise false. isThreadContentionMonitoringEnabled
- public boolean isThreadContentionMonitoringEnabled( )
java.lang.management.ThreadMXBean
isThreadContentionMonitoringEnabled in interface java.lang.management.ThreadMXBean
true if thread contention monitoring is enabled,
false otherwise. isThreadContentionMonitoringSupported
- public boolean isThreadContentionMonitoringSupported( )
java.lang.management.ThreadMXBean
isThreadContentionMonitoringSupported in interface java.lang.management.ThreadMXBean
true if thread contention monitoring is supported,
false otherwise. isThreadCpuTimeEnabled
- public boolean isThreadCpuTimeEnabled( )
java.lang.management.ThreadMXBean
isThreadCpuTimeEnabled in interface java.lang.management.ThreadMXBean
true if thread CPU timing is enabled,
false otherwise. ThreadMXBean.isThreadCpuTimeSupported()isThreadCpuTimeSupported
- public boolean isThreadCpuTimeSupported( )
java.lang.management.ThreadMXBean
isThreadCpuTimeSupported in interface java.lang.management.ThreadMXBean
true if the virtual machine supports the CPU
timing of threads, false otherwise. resetPeakThreadCount
- public void resetPeakThreadCount( )
java.lang.management.ThreadMXBean
resetPeakThreadCount in interface java.lang.management.ThreadMXBean
setThreadContentionMonitoringEnabled
- public void setThreadContentionMonitoringEnabled( boolean enable)
java.lang.management.ThreadMXBean
If it is supported, the virtual machine will initially not monitor thread contention situations.
setThreadContentionMonitoringEnabled in interface java.lang.management.ThreadMXBean
enable - enable thread contention monitoring if true,
otherwise disable thread contention monitoring. ThreadMXBean.isThreadContentionMonitoringSupported()setThreadCpuTimeEnabled
- public void setThreadCpuTimeEnabled( boolean enable)
java.lang.management.ThreadMXBean
The default value of this property depends on the underlying operating system on which the virtual machine is running.
setThreadCpuTimeEnabled in interface java.lang.management.ThreadMXBean
enable - enable thread CPU timing if true, otherwise
disable thread CPU timing ThreadMXBean.isThreadCpuTimeSupported()isObjectMonitorUsageSupported
- public boolean isObjectMonitorUsageSupported( )
java.lang.management.ThreadMXBean
isObjectMonitorUsageSupported in interface java.lang.management.ThreadMXBean
true if object monitor usage is permitted,
otherwise false isSynchronizerUsageSupported
- public boolean isSynchronizerUsageSupported( )
java.lang.management.ThreadMXBean
AbstractOwnableSynchronizer type and which are
completely owned by a single thread).
isSynchronizerUsageSupported in interface java.lang.management.ThreadMXBean
true if synchronizer usage monitoring is
permitted, otherwise false findDeadlockedThreads
- public long[] findDeadlockedThreads( )
java.lang.management.ThreadMXBean
long id of all threads currently waiting on object
monitors or ownable synchronizers (synchronizers that make use of the
AbstractOwnableSynchronizer type and which are completely
owned by a single thread). To determine the threads currently deadlocked
by object monitors only use the ThreadMXBean.findMonitorDeadlockedThreads()
method.
It is recommended that this method be used solely for problem determination analysis and not as a means of managing thread synchronization in a virtual machine. This is because the method may be very expensive to run.
findDeadlockedThreads in interface java.lang.management.ThreadMXBean
null is returned. ThreadMXBean.isSynchronizerUsageSupported()dumpAllThreads
- public java.lang.management.ThreadInfo[] dumpAllThreads( boolean lockedMonitors,
- boolean lockedSynchronizers)
java.lang.management.ThreadMXBean
ThreadInfo objects holding information on all
threads that were alive when the call was invoked.
dumpAllThreads in interface java.lang.management.ThreadMXBean
lockedMonitors - boolean indication of whether or not information on all
currently locked object monitors is to be included in the
returned array lockedSynchronizers - boolean indication of whether or not information on all
currently locked ownable synchronizers is to be included in
the returned array ThreadInfo objects
java.lang.management.ThreadMXBean