This class is not part of the public API.

Class: sun.management.ThreadImpl

Implementation class for the thread subsystem. Standard and committed hotspot-specific metrics if any. ManagementFactory.getThreadMXBean() returns an instance of this class.

Inheritance

Superclass tree: Implements:

Methods

  • ThreadImpltop

    ThreadImpl(VMManagement vm)
    Constructor of ThreadImpl class.
    Google Code Search
    Stack Overflow
  • dumpAllThreadstop

    public ThreadInfo[] dumpAllThreads(boolean lockedMonitors, boolean lockedSynchronizers)
    Returns the thread info for all live threads with stack trace and synchronization information. Some threads included in the returned array may have been terminated when this method returns.

    This method returns an array of java.lang.management.ThreadInfo objects as specified in the java.lang.management.ThreadMXBean.getThreadInfo(long[], boolean, boolean) method.

    Parameters:
    @param lockedMonitors if true, dump all locked monitors.
    @param lockedSynchronizers if true, dump all locked ownable synchronizers.
    Return:
    @return an array of java.lang.management.ThreadInfo for all live threads.
    Specified by:
    dumpAllThreads from ThreadMXBean
    Google Code Search
    Stack Overflow
  • dumpThreads0top

    static native private ThreadInfo[] dumpThreads0(long[] ids, boolean lockedMonitors, boolean lockedSynchronizers)
    Google Code Search
    Stack Overflow
  • findDeadlockedThreadstop

    public long[] findDeadlockedThreads()
    Finds cycles of threads that are in deadlock waiting to acquire object monitors or ownable synchronizers. 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 thread in the cycle.

    This method is designed for troubleshooting use, but not for synchronization control. It might be an expensive operation.

    Return:
    @return an array of IDs of the threads that are deadlocked waiting for object monitors or ownable synchronizers, if any; null otherwise.
    Specified by:
    findDeadlockedThreads from ThreadMXBean
    Google Code Search
    Stack Overflow
  • findDeadlockedThreads0top

    static native private Thread[] findDeadlockedThreads0()
    Google Code Search
    Stack Overflow
  • findMonitorDeadlockedThreadstop

    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 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.

    This method finds deadlocks involving only object monitors. To find deadlocks involving both object monitors and ownable synchronizers, the findDeadlockedThreads method should be used.

    Return:
    @return an array of IDs of the threads that are monitor deadlocked, if any; null otherwise.
    Google Code Search
    Stack Overflow
  • findMonitorDeadlockedThreads0top

    static native private Thread[] findMonitorDeadlockedThreads0()
    Google Code Search
    Stack Overflow
  • getAllThreadIdstop

    public long[] getAllThreadIds()
    Returns all live thread IDs. Some threads included in the returned array may have been terminated when this method returns.
    Return:
    @return an array of long, each is a thread ID.
    Specified by:
    getAllThreadIds from ThreadMXBean
    Google Code Search
    Stack Overflow
  • getCurrentThreadCpuTimetop

    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 convenient method for local management use and is equivalent to calling:

       getThreadCpuTime(Thread.currentThread().getId());
     
    Return:
    @return the total CPU time for the current thread if CPU time measurement is enabled; -1 otherwise.
    Google Code Search
    Stack Overflow
  • getCurrentThreadUserTimetop

    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 convenient method for local management use and is equivalent to calling:

       getThreadUserTime(Thread.currentThread().getId());
     
    Return:
    @return the user-level CPU time for the current thread if CPU time measurement is enabled; -1 otherwise.
    Google Code Search
    Stack Overflow
  • getDaemonThreadCounttop

    public int getDaemonThreadCount()
    Returns the current number of live daemon threads.
    Return:
    @return the current number of live daemon threads.
    Specified by:
    getDaemonThreadCount from ThreadMXBean
    Google Code Search
    Stack Overflow
  • getPeakThreadCounttop

    public int getPeakThreadCount()
    Returns the peak live thread count since the Java virtual machine started or peak was reset.
    Return:
    @return the peak live thread count.
    Specified by:
    getPeakThreadCount from ThreadMXBean
    Google Code Search
    Stack Overflow
  • getThreadCounttop

    public int getThreadCount()
    Returns the current number of live threads including both daemon and non-daemon threads.
    Return:
    @return the current number of live threads.
    Specified by:
    getThreadCount from ThreadMXBean
    Google Code Search
    Stack Overflow
  • getThreadCpuTimetop

    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.

    Parameters:
    @param id the thread ID of a thread
    Return:
    @return the total CPU time for a thread of the specified ID if the thread of the specified ID exists, the thread is alive, and CPU time measurement is enabled; -1 otherwise.
    Specified by:
    getThreadCpuTime from ThreadMXBean
    Google Code Search
    Stack Overflow
  • getThreadInfotop

    public 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:
    getThreadInfo(id, 0);

    This method returns a ThreadInfo object representing the thread information for the thread of the specified ID. The stack trace, locked monitors, and locked synchronizers in the returned ThreadInfo object will be empty. 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 the ThreadInfo.from method.

    Parameters:
    @param id the thread ID of the thread. Must be positive.
    Return:
    @return a java.lang.management.ThreadInfo object for the thread of the given ID with no stack trace, no locked monitor and no synchronizer info; null if the thread of the given ID is not alive or it does not exist.
    Specified by:
    getThreadInfo from ThreadMXBean
    Google Code Search
    Stack Overflow
  • getThreadInfotop

    public ThreadInfo getThreadInfo(long id, int maxDepth)
    Returns a thread info for a thread of the specified id, with stack trace of a specified number of stack trace elements. 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. 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 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 the ThreadInfo.from method.

    Parameters:
    @param id the thread ID of the thread. Must be positive.
    @param 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.
    Return:
    @return a java.lang.management.ThreadInfo of the thread of the given ID with no locked monitor and synchronizer info. null if the thread of the given ID is not alive or it does not exist.
    Specified by:
    getThreadInfo from ThreadMXBean
    Google Code Search
    Stack Overflow
  • getThreadInfotop

    public 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:
       getThreadInfo(ids, 0);
     

    This method returns an array of the ThreadInfo objects. The stack trace, locked monitors, and locked synchronizers in each ThreadInfo object will be empty. 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 the ThreadInfo.from method.

    Parameters:
    @param ids an array of thread IDs.
    Return:
    @return an array of the java.lang.management.ThreadInfo objects, 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.
    Specified by:
    getThreadInfo from ThreadMXBean
    Google Code Search
    Stack Overflow
  • getThreadInfotop

    public ThreadInfo[] getThreadInfo(long[] ids, int maxDepth)
    Returns the thread info for each thread whose ID is in the input array ids, with stack trace of a specified number of stack trace elements. 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. 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 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 the ThreadInfo.from method.

    Parameters:
    @param ids an array of thread IDs
    @param 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.
    Return:
    @return an array of the java.lang.management.ThreadInfo objects, 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.
    Specified by:
    getThreadInfo from ThreadMXBean
    Google Code Search
    Stack Overflow
  • getThreadInfotop

    public ThreadInfo[] getThreadInfo(long[] ids, boolean lockedMonitors, boolean lockedSynchronizers)
    Returns the thread info for each thread whose ID is in the input array ids, with stack trace and synchronization information.

    This method obtains a snapshot of the thread information for each thread including:

    • the entire stack trace,
    • the object monitors currently locked by the thread if lockedMonitors is true, and
    • the ownable synchronizers currently locked by the thread if lockedSynchronizers is true.

    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.

    If a thread does not lock any object monitor or lockedMonitors is false, the returned ThreadInfo object will have an empty MonitorInfo array. Similarly, if a thread does not lock any synchronizer or lockedSynchronizers is false, the returned ThreadInfo object will have an empty LockInfo array.

    When both lockedMonitors and lockedSynchronizers parameters are false, it is equivalent to calling:

         getThreadInfo(ids, Integer.MAX_VALUE)
     

    This method is designed for troubleshooting use, but not for synchronization control. It might be an expensive operation.

    MBeanServer access:
    The mapped type of ThreadInfo is CompositeData with attributes as specified in the ThreadInfo.from method.

    Parameters:
    @param ids an array of thread IDs.
    @param lockedMonitors if true, retrieves all locked monitors.
    @param lockedSynchronizers if true, retrieves all locked ownable synchronizers.
    Return:
    @return an array of the java.lang.management.ThreadInfo objects, each containing information about a thread whose ID is in the corresponding element of the input array of IDs.
    Specified by:
    getThreadInfo from ThreadMXBean
    Google Code Search
    Stack Overflow
  • getThreadInfo0top

    static native private void getThreadInfo0(long[] ids, int maxDepth, ThreadInfo[] result)
    Google Code Search
    Stack Overflow
  • getThreadTotalCpuTime0top

    static native private long getThreadTotalCpuTime0(long id)
    Google Code Search
    Stack Overflow
  • getThreadUserCpuTime0top

    static native private long getThreadUserCpuTime0(long id)
    Google Code Search
    Stack Overflow
  • getThreadUserTimetop

    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.

    Parameters:
    @param id the thread ID of a thread
    Return:
    @return the user-level CPU time for a thread of the specified ID if the thread of the specified ID exists, the thread is alive, and CPU time measurement is enabled; -1 otherwise.
    Specified by:
    getThreadUserTime from ThreadMXBean
    Google Code Search
    Stack Overflow
  • getThreadstop

    static native private Thread[] getThreads()
    Google Code Search
    Stack Overflow
  • getTotalStartedThreadCounttop

    public long getTotalStartedThreadCount()
    Returns the total number of threads created and also started since the Java virtual machine started.
    Return:
    @return the total number of threads started.
    Google Code Search
    Stack Overflow
  • isCurrentThreadCpuTimeSupportedtop

    public boolean isCurrentThreadCpuTimeSupported()
    Tests if the Java virtual machine supports CPU time measurement for the current thread. This method returns true if java.lang.management.ThreadMXBean.isThreadCpuTimeSupported() returns true.
    Return:
    @return true if the Java virtual machine supports CPU time measurement for current thread; false otherwise.
    Google Code Search
    Stack Overflow
  • isObjectMonitorUsageSupportedtop

    public boolean isObjectMonitorUsageSupported()
    Tests if the Java virtual machine supports monitoring of object monitor usage.
    Return:
    @return true if the Java virtual machine supports monitoring of object monitor usage; false otherwise.
    Google Code Search
    Stack Overflow
  • isSynchronizerUsageSupportedtop

    public boolean isSynchronizerUsageSupported()
    Tests if the Java virtual machine supports monitoring of ownable synchronizer usage.
    Return:
    @return true if the Java virtual machine supports monitoring of ownable synchronizer usage; false otherwise.
    Google Code Search
    Stack Overflow
  • isThreadContentionMonitoringEnabledtop

    public synchronized boolean isThreadContentionMonitoringEnabled()
    Tests if thread contention monitoring is enabled.
    Return:
    @return true if thread contention monitoring is enabled; false otherwise.
    Google Code Search
    Stack Overflow
  • isThreadContentionMonitoringSupportedtop

    public boolean isThreadContentionMonitoringSupported()
    Tests if the Java virtual machine supports thread contention monitoring.
    Return:
    @return true if the Java virtual machine supports thread contention monitoring; false otherwise.
    Google Code Search
    Stack Overflow
  • isThreadCpuTimeEnabledtop

    public boolean isThreadCpuTimeEnabled()
    Tests if thread CPU time measurement is enabled.
    Return:
    @return true if thread CPU time measurement is enabled; false otherwise.
    Google Code Search
    Stack Overflow
  • isThreadCpuTimeSupportedtop

    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.
    Return:
    @return true if the Java virtual machine supports CPU time measurement for any thread; false otherwise.
    Google Code Search
    Stack Overflow
  • resetContentionTimes0top

    static native private void resetContentionTimes0(long tid)
    Google Code Search
    Stack Overflow
  • resetPeakThreadCounttop

    public void resetPeakThreadCount()
    Resets the peak thread count to the current number of live threads.
    Specified by:
    resetPeakThreadCount from ThreadMXBean
    Google Code Search
    Stack Overflow
  • resetPeakThreadCount0top

    static native private void resetPeakThreadCount0()
    Google Code Search
    Stack Overflow
  • setThreadContentionMonitoringEnabledtop

    public void setThreadContentionMonitoringEnabled(boolean enable)
    Enables or disables thread contention monitoring. Thread contention monitoring is disabled by default.
    Parameters:
    @param enable true to enable; false to disable.
    Google Code Search
    Stack Overflow
  • setThreadContentionMonitoringEnabled0top

    static native private void setThreadContentionMonitoringEnabled0(boolean enable)
    Google Code Search
    Stack Overflow
  • setThreadCpuTimeEnabledtop

    public void setThreadCpuTimeEnabled(boolean enable)
    Enables or disables thread CPU time measurement. The default is platform dependent.
    Parameters:
    @param enable true to enable; false to disable.
    Google Code Search
    Stack Overflow
  • setThreadCpuTimeEnabled0top

    static native private void setThreadCpuTimeEnabled0(boolean enable)
    Google Code Search
    Stack Overflow

Fields

  • contentionMonitoringEnabled

    private boolean contentionMonitoringEnabled
  • cpuTimeEnabled

    private boolean cpuTimeEnabled
  • jvm

    final private VMManagement jvm