Methods Summary |
---|
public long[] | findMonitorDeadlockedThreads()Finds cycles of threads that are in deadlock waiting to acquire
object monitors. That is, threads that are blocked waiting to enter a
synchronization block or waiting to reenter a synchronization block
after an {@link Object#wait 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.
|
public long[] | getAllThreadIds()Returns all live thread IDs.
Some threads included in the returned array
may have been terminated when this method returns.
|
public long | getCurrentThreadCpuTime()Returns the total CPU time for the current thread in nanoseconds.
The returned value is of nanoseconds precison 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 convenient method for local management use and is
equivalent to calling:
{@link #getThreadCpuTime getThreadCpuTime}(Thread.currentThread().getId());
|
public long | getCurrentThreadUserTime()Returns the CPU time that the current thread has executed
in user mode in nanoseconds.
The returned value is of nanoseconds precison but
not necessarily nanoseconds accuracy.
This is a convenient method for local management use and is
equivalent to calling:
{@link #getThreadUserTime getThreadUserTime}(Thread.currentThread().getId());
|
public int | getDaemonThreadCount()Returns the current number of live daemon threads.
|
public int | getPeakThreadCount()Returns the peak live thread count since the Java virtual machine
started or peak was reset.
|
public int | getThreadCount()Returns the current number of live threads including both
daemon and non-daemon threads.
|
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 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.
|
public java.lang.management.ThreadInfo | getThreadInfo(long id)Returns the thread info for a thread of the specified
id with no stack trace. This method is equivalent to calling:
{@link #getThreadInfo(long, int) 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
{@link ThreadInfo#from ThreadInfo}.
|
public java.lang.management.ThreadInfo[] | getThreadInfo(long[] ids)Returns the thread info for each thread
whose ID is in the input array ids with no
stack trace. This method is equivalent to calling:
{@link #getThreadInfo(long[], int) 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
{@link ThreadInfo#from ThreadInfo}.
|
public java.lang.management.ThreadInfo | getThreadInfo(long id, int maxDepth)Returns a thread info for a thread of
the specified id.
The maxDepth parameter indicates the maximum number of
StackTraceElement to be retrieved from the stack trace.
If maxDepth == Integer.MAX_VALUE, the entire stack trace of
the thread will be dumped.
If maxDepth == 0, no stack trace of the thread
will be dumped.
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
{@link ThreadInfo#from ThreadInfo}.
|
public java.lang.management.ThreadInfo[] | getThreadInfo(long[] ids, int maxDepth)Returns the thread info for each thread
whose ID is in the input array ids.
The maxDepth parameter indicates the maximum number of
StackTraceElement to be retrieved from the stack trace.
If maxDepth == Integer.MAX_VALUE, the entire stack trace of
the thread will be dumped.
If maxDepth == 0, no stack trace of the thread
will be dumped.
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
{@link ThreadInfo#from ThreadInfo}.
|
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 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.
|
public long | getTotalStartedThreadCount()Returns the total number of threads created and also started
since the Java virtual machine started.
|
public boolean | isCurrentThreadCpuTimeSupported()Tests if the Java virtual machine supports CPU time
measurement for the current thread.
This method returns true if {@link #isThreadCpuTimeSupported}
returns true.
|
public boolean | isThreadContentionMonitoringEnabled()Tests if thread contention monitoring is enabled.
|
public boolean | isThreadContentionMonitoringSupported()Tests if the Java virtual machine supports thread contention monitoring.
|
public boolean | isThreadCpuTimeEnabled()Tests if thread CPU time measurement is enabled.
|
public boolean | isThreadCpuTimeSupported()Tests if the Java virtual machine implementation supports CPU time
measurement for any thread.
A Java virtual machine implementation that supports CPU time
measurement for any thread will also support CPU time
measurement for the current thread.
|
public void | resetPeakThreadCount()Resets the peak thread count to the current number of
live threads.
|
public void | setThreadContentionMonitoringEnabled(boolean enable)Enables or disables thread contention monitoring.
Thread contention monitoring is disabled by default.
|
public void | setThreadCpuTimeEnabled(boolean enable)Enables or disables thread CPU time measurement. The default
is platform dependent.
|