|
Préférences
Moteurs de recherche
|
||||||||||||||||||||||||||||||||||||||||||||||
JavaTM 2 Platform Std. Ed. v1.5.0
java.lang.management
|
Method Summary | |
---|---|
long[] |
findMonitorDeadlockedThreads()
Finds cycles of threads that are in deadlock waiting to acquire object monitors. |
long[] |
getAllThreadIds()
Returns all live thread IDs. |
long |
getCurrentThreadCpuTime()
Returns the total CPU time for the current thread in nanoseconds. |
long |
getCurrentThreadUserTime()
Returns the CPU time that the current thread has executed in user mode in nanoseconds. |
int |
getDaemonThreadCount()
Returns the current number of live daemon threads. |
int |
getPeakThreadCount()
Returns the peak live thread count since the Java virtual machine started or peak was reset. |
int |
getThreadCount()
Returns the current number of live threads including both daemon and non-daemon threads. |
long |
getThreadCpuTime(long id)
Returns the total CPU time for a thread of the specified ID in nanoseconds. |
ThreadInfo |
getThreadInfo(long id)
Returns the thread info for a thread of the specified id with no stack trace. |
ThreadInfo[] |
getThreadInfo(long[] ids)
Returns the thread info for each thread whose ID is in the input array ids with no stack trace. |
ThreadInfo[] |
getThreadInfo(long[] ids,
int maxDepth)
Returns the thread info for each thread whose ID is in the input array ids. |
ThreadInfo |
getThreadInfo(long id,
int maxDepth)
Returns a thread info for a thread of the specified id. |
long |
getThreadUserTime(long id)
Returns the CPU time that a thread of the specified ID has executed in user mode in nanoseconds. |
long |
getTotalStartedThreadCount()
Returns the total number of threads created and also started since the Java virtual machine started. |
boolean |
isCurrentThreadCpuTimeSupported()
Tests if the Java virtual machine supports CPU time measurement for the current thread. |
boolean |
isThreadContentionMonitoringEnabled()
Tests if thread contention monitoring is enabled. |
boolean |
isThreadContentionMonitoringSupported()
Tests if the Java virtual machine supports thread contention monitoring. |
boolean |
isThreadCpuTimeEnabled()
Tests if thread CPU time measurement is enabled. |
boolean |
isThreadCpuTimeSupported()
Tests if the Java virtual machine implementation supports CPU time measurement for any thread. |
void |
resetPeakThreadCount()
Resets the peak thread count to the current number of live threads. |
void |
setThreadContentionMonitoringEnabled(boolean enable)
Enables or disables thread contention monitoring. |
void |
setThreadCpuTimeEnabled(boolean enable)
Enables or disables thread CPU time measurement. |
Method Detail |
---|
int getThreadCount()
int getPeakThreadCount()
long getTotalStartedThreadCount()
int getDaemonThreadCount()
long[] getAllThreadIds()
SecurityException
- if a security manager
exists and the caller does not have
ManagementPermission("monitor").ThreadInfo getThreadInfo(long id)
getThreadInfo(id, 0);
This method returns a ThreadInfo object representing the thread information for the thread of the specified ID. The stack trace in the returned ThreadInfo object will be an empty array of StackTraceElement. If a thread of the given ID 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 died.
MBeanServer access:
The mapped type of ThreadInfo is
CompositeData with attributes as specified in
ThreadInfo
.
id
- the thread ID of the thread. Must be positive.
ThreadInfo
object for the thread of the given ID
with no stack trace;
null if the thread of the given ID is not alive or
it does not exist.
IllegalArgumentException
- if id <= 0.
SecurityException
- if a security manager
exists and the caller does not have
ManagementPermission("monitor").ThreadInfo[] getThreadInfo(long[] ids)
getThreadInfo
(ids, 0);
This method returns an array of the ThreadInfo objects. The stack trace in each ThreadInfo object will be an empty array of StackTraceElement. If a thread of a given ID is not alive or does not exist, the corresponding element in the returned array will contain null. A thread is alive if it has been started and has not yet died.
MBeanServer access:
The mapped type of ThreadInfo is
CompositeData with attributes as specified in
ThreadInfo
.
ids
- an array of thread IDs
ThreadInfo
objects, each containing
information about a thread whose ID is in the corresponding
element of the input array of IDs.
IllegalArgumentException
- if any element in the input array
ids is <= 0.
SecurityException
- if a security manager
exists and the caller does not have
ManagementPermission("monitor").ThreadInfo getThreadInfo(long id, int maxDepth)
When the Java virtual machine has no stack trace information about a thread or maxDepth == 0, the stack trace in the ThreadInfo object will be an empty array of StackTraceElement.
If a thread of the given ID 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 died.
MBeanServer access:
The mapped type of ThreadInfo is
CompositeData with attributes as specified in
ThreadInfo
.
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_VALUE could be used to request
the entire stack to be dumped.
ThreadInfo
of the thread of the given ID.
null if the thread of the given ID is not alive or
it does not exist.
IllegalArgumentException
- if id <= 0.
IllegalArgumentException
- if maxDepth is negative.
SecurityException
- if a security manager
exists and the caller does not have
ManagementPermission("monitor").ThreadInfo[] getThreadInfo(long[] ids, int maxDepth)
When the Java virtual machine has no stack trace information about a thread or maxDepth == 0, the stack trace in the ThreadInfo object will be an empty array of StackTraceElement.
This method returns an array of the ThreadInfo objects, each is the thread information about the thread with the same index as in the ids array. If a thread of the given ID is not alive or does not exist, null will be set in the corresponding element in the returned array. A thread is alive if it has been started and has not yet died.
MBeanServer access:
The mapped type of ThreadInfo is
CompositeData with attributes as specified in
ThreadInfo
.
ids
- an array of thread IDsmaxDepth
- the maximum number of entries in the stack trace
to be dumped. Integer.MAX_VALUE could be used to request
the entire stack to be dumped.
ThreadInfo
objects, each containing
information about a thread whose ID is in the corresponding
element of the input array of IDs.
IllegalArgumentException
- if maxDepth is negative.
IllegalArgumentException
- if any element in the input array
ids is <= 0.
SecurityException
- if a security manager
exists and the caller does not have
ManagementPermission("monitor").boolean isThreadContentionMonitoringSupported()
boolean isThreadContentionMonitoringEnabled()
UnsupportedOperationException
- if the Java virtual
machine does not support thread contention monitoring.isThreadContentionMonitoringSupported()
void setThreadContentionMonitoringEnabled(boolean enable)
enable
- true to enable;
false to disable.
UnsupportedOperationException
- if the Java
virtual machine does not support thread contention monitoring.
SecurityException
- if a security manager
exists and the caller does not have
ManagementPermission("control").isThreadContentionMonitoringSupported()
long getCurrentThreadCpuTime()
This is a convenient method for local management use and is equivalent to calling:
getThreadCpuTime
(Thread.currentThread().getId());
UnsupportedOperationException
- if the Java
virtual machine does not support CPU time measurement for
the current thread.getCurrentThreadUserTime()
,
isCurrentThreadCpuTimeSupported()
,
isThreadCpuTimeEnabled()
,
setThreadCpuTimeEnabled(boolean)
long getCurrentThreadUserTime()
This is a convenient method for local management use and is equivalent to calling:
getThreadUserTime
(Thread.currentThread().getId());
UnsupportedOperationException
- if the Java
virtual machine does not support CPU time measurement for
the current thread.getCurrentThreadCpuTime()
,
isCurrentThreadCpuTimeSupported()
,
isThreadCpuTimeEnabled()
,
setThreadCpuTimeEnabled(boolean)
long getThreadCpuTime(long id)
If the thread of the specified ID 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 died.
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.
id
- the thread ID of a thread
IllegalArgumentException
- if id <= 0 .
UnsupportedOperationException
- if the Java
virtual machine does not support CPU time measurement for
other threads.getThreadUserTime(long)
,
isThreadCpuTimeSupported()
,
isThreadCpuTimeEnabled()
,
setThreadCpuTimeEnabled(boolean)
long getThreadUserTime(long id)
If the thread of the specified ID 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 died.
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.
id
- the thread ID of a thread
IllegalArgumentException
- if id <= 0 .
UnsupportedOperationException
- if the Java
virtual machine does not support CPU time measurement for
other threads.getThreadCpuTime(long)
,
isThreadCpuTimeSupported()
,
isThreadCpuTimeEnabled()
,
setThreadCpuTimeEnabled(boolean)
boolean isThreadCpuTimeSupported()
boolean isCurrentThreadCpuTimeSupported()
isThreadCpuTimeSupported()
returns true.
boolean isThreadCpuTimeEnabled()
UnsupportedOperationException
- if the Java virtual
machine does not support CPU time measurement for other threads
nor for the current thread.isThreadCpuTimeSupported()
,
isCurrentThreadCpuTimeSupported()
void setThreadCpuTimeEnabled(boolean enable)
enable
- true to enable;
false to disable.
UnsupportedOperationException
- if the Java
virtual machine does not support CPU time measurement for
any threads nor for the current thread.
SecurityException
- if a security manager
exists and the caller does not have
ManagementPermission("control").isThreadCpuTimeSupported()
,
isCurrentThreadCpuTimeSupported()
long[] findMonitorDeadlockedThreads()
Object.wait
call,
where each thread owns one monitor while
trying to obtain another monitor already held by another thread
in a cycle.
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.
SecurityException
- if a security manager
exists and the caller does not have
ManagementPermission("monitor").void resetPeakThreadCount()
SecurityException
- if a security manager
exists and the caller does not have
ManagementPermission("control").getPeakThreadCount()
,
getThreadCount()