Class ExtendedThreadMXBeanImpl

java.lang.Object
com.ibm.java.lang.management.internal.ThreadMXBeanImpl
com.ibm.lang.management.internal.ExtendedThreadMXBeanImpl
All Implemented Interfaces:
ThreadMXBean, ThreadMXBean, PlatformManagedObject, ThreadMXBean

public final class ExtendedThreadMXBeanImpl extends com.ibm.java.lang.management.internal.ThreadMXBeanImpl implements ThreadMXBean
Implementation of the extended ThreadMXBean.
  • Method Details

    • getInstance

      public static ThreadMXBean 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 interface ThreadMXBean
      Parameters:
      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
      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 interface ThreadMXBean
      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 array ids. 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 array ids and setting the returned value in the corresponding element of the returned array.

      Specified by:
      getThreadAllocatedBytes in interface ThreadMXBean
      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 array ids 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 array ids and setting the returned value in the corresponding element of the returned array.

      Specified by:
      getThreadCpuTime in interface ThreadMXBean
      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 array ids 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 array ids and setting the returned value in the corresponding element of the returned array.

      Specified by:
      getThreadUserTime in interface ThreadMXBean
      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 interface ThreadMXBean
      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 interface ThreadMXBean
      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 interface ThreadMXBean
      Parameters:
      value - true to enable; false to disable.
      See Also: