< prev index next >

src/java.management/share/classes/java/lang/management/ThreadMXBean.java

Print this page


   1 /*
   2  * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  32  * the Java virtual machine.
  33  *
  34  * <p> A Java virtual machine has a single instance of the implementation
  35  * class of this interface.  This instance implementing this interface is
  36  * an <a href="ManagementFactory.html#MXBean">MXBean</a>
  37  * that can be obtained by calling
  38  * the {@link ManagementFactory#getThreadMXBean} method or
  39  * from the {@link ManagementFactory#getPlatformMBeanServer
  40  * platform MBeanServer} method.
  41  *
  42  * <p>The {@code ObjectName} for uniquely identifying the MXBean for
  43  * the thread system within an MBeanServer is:
  44  * <blockquote>
  45  *    {@link ManagementFactory#THREAD_MXBEAN_NAME
  46  *           java.lang:type=Threading}
  47  * </blockquote>
  48  *
  49  * It can be obtained by calling the
  50  * {@link PlatformManagedObject#getObjectName} method.
  51  *
  52  * <h2>Thread ID</h2>
  53  * Thread ID is a positive long value returned by calling the
  54  * {@link java.lang.Thread#getId} method for a thread.
  55  * The thread ID is unique during its lifetime.  When a thread
  56  * is terminated, this thread ID may be reused.
  57  *
  58  * <p> Some methods in this interface take a thread ID or an array
  59  * of thread IDs as the input parameter and return per-thread information.
  60  *
  61  * <h2>Thread CPU time</h2>
  62  * A Java virtual machine implementation may support measuring
  63  * the CPU time for the current thread, for any thread, or for no threads.
  64  *
  65  * <p>
  66  * The {@link #isThreadCpuTimeSupported} method can be used to determine
  67  * if a Java virtual machine supports measuring of the CPU time for any
  68  * thread.  The {@link #isCurrentThreadCpuTimeSupported} method can
  69  * be used to determine if a Java virtual machine supports measuring of
  70  * the CPU time for the current  thread.
  71  * A Java virtual machine implementation that supports CPU time measurement
  72  * for any thread will also support that for the current thread.
  73  *
  74  * <p> The CPU time provided by this interface has nanosecond precision
  75  * but not necessarily nanosecond accuracy.
  76  *
  77  * <p>
  78  * A Java virtual machine may disable CPU time measurement
  79  * by default.
  80  * The {@link #isThreadCpuTimeEnabled} and {@link #setThreadCpuTimeEnabled}
  81  * methods can be used to test if CPU time measurement is enabled
  82  * and to enable/disable this support respectively.
  83  * Enabling thread CPU measurement could be expensive in some
  84  * Java virtual machine implementations.
  85  *
  86  * <h2>Thread Contention Monitoring</h2>
  87  * Some Java virtual machines may support thread contention monitoring.
  88  * When thread contention monitoring is enabled, the accumulated elapsed
  89  * time that the thread has blocked for synchronization or waited for
  90  * notification will be collected and returned in the
  91  * <a href="ThreadInfo.html#SyncStats">{@code ThreadInfo}</a> object.
  92  * <p>
  93  * The {@link #isThreadContentionMonitoringSupported} method can be used to
  94  * determine if a Java virtual machine supports thread contention monitoring.
  95  * The thread contention monitoring is disabled by default.  The
  96  * {@link #setThreadContentionMonitoringEnabled} method can be used to enable
  97  * thread contention monitoring.
  98  *
  99  * <h2>Synchronization Information and Deadlock Detection</h2>
 100  * Some Java virtual machines may support monitoring of
 101  * {@linkplain #isObjectMonitorUsageSupported object monitor usage} and
 102  * {@linkplain #isSynchronizerUsageSupported ownable synchronizer usage}.
 103  * The {@link #getThreadInfo(long[], boolean, boolean)} and
 104  * {@link #dumpAllThreads} methods can be used to obtain the thread stack trace
 105  * and synchronization information including which
 106  * {@linkplain LockInfo <i>lock</i>} a thread is blocked to
 107  * acquire or waiting on and which locks the thread currently owns.
 108  * <p>
 109  * The {@code ThreadMXBean} interface provides the
 110  * {@link #findMonitorDeadlockedThreads} and
 111  * {@link #findDeadlockedThreads} methods to find deadlocks in
 112  * the running application.
 113  *
 114  * @see ManagementFactory#getPlatformMXBeans(Class)
 115  * @see <a href="../../../javax/management/package-summary.html">
 116  *      JMX Specification.</a>
 117  * @see <a href="package-summary.html#examples">
 118  *      Ways to Access MXBeans</a>
 119  *


   1 /*
   2  * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  32  * the Java virtual machine.
  33  *
  34  * <p> A Java virtual machine has a single instance of the implementation
  35  * class of this interface.  This instance implementing this interface is
  36  * an <a href="ManagementFactory.html#MXBean">MXBean</a>
  37  * that can be obtained by calling
  38  * the {@link ManagementFactory#getThreadMXBean} method or
  39  * from the {@link ManagementFactory#getPlatformMBeanServer
  40  * platform MBeanServer} method.
  41  *
  42  * <p>The {@code ObjectName} for uniquely identifying the MXBean for
  43  * the thread system within an MBeanServer is:
  44  * <blockquote>
  45  *    {@link ManagementFactory#THREAD_MXBEAN_NAME
  46  *           java.lang:type=Threading}
  47  * </blockquote>
  48  *
  49  * It can be obtained by calling the
  50  * {@link PlatformManagedObject#getObjectName} method.
  51  *
  52  * <h3>Thread ID</h3>
  53  * Thread ID is a positive long value returned by calling the
  54  * {@link java.lang.Thread#getId} method for a thread.
  55  * The thread ID is unique during its lifetime.  When a thread
  56  * is terminated, this thread ID may be reused.
  57  *
  58  * <p> Some methods in this interface take a thread ID or an array
  59  * of thread IDs as the input parameter and return per-thread information.
  60  *
  61  * <h3>Thread CPU time</h3>
  62  * A Java virtual machine implementation may support measuring
  63  * the CPU time for the current thread, for any thread, or for no threads.
  64  *
  65  * <p>
  66  * The {@link #isThreadCpuTimeSupported} method can be used to determine
  67  * if a Java virtual machine supports measuring of the CPU time for any
  68  * thread.  The {@link #isCurrentThreadCpuTimeSupported} method can
  69  * be used to determine if a Java virtual machine supports measuring of
  70  * the CPU time for the current  thread.
  71  * A Java virtual machine implementation that supports CPU time measurement
  72  * for any thread will also support that for the current thread.
  73  *
  74  * <p> The CPU time provided by this interface has nanosecond precision
  75  * but not necessarily nanosecond accuracy.
  76  *
  77  * <p>
  78  * A Java virtual machine may disable CPU time measurement
  79  * by default.
  80  * The {@link #isThreadCpuTimeEnabled} and {@link #setThreadCpuTimeEnabled}
  81  * methods can be used to test if CPU time measurement is enabled
  82  * and to enable/disable this support respectively.
  83  * Enabling thread CPU measurement could be expensive in some
  84  * Java virtual machine implementations.
  85  *
  86  * <h3>Thread Contention Monitoring</h3>
  87  * Some Java virtual machines may support thread contention monitoring.
  88  * When thread contention monitoring is enabled, the accumulated elapsed
  89  * time that the thread has blocked for synchronization or waited for
  90  * notification will be collected and returned in the
  91  * <a href="ThreadInfo.html#SyncStats">{@code ThreadInfo}</a> object.
  92  * <p>
  93  * The {@link #isThreadContentionMonitoringSupported} method can be used to
  94  * determine if a Java virtual machine supports thread contention monitoring.
  95  * The thread contention monitoring is disabled by default.  The
  96  * {@link #setThreadContentionMonitoringEnabled} method can be used to enable
  97  * thread contention monitoring.
  98  *
  99  * <h3>Synchronization Information and Deadlock Detection</h3>
 100  * Some Java virtual machines may support monitoring of
 101  * {@linkplain #isObjectMonitorUsageSupported object monitor usage} and
 102  * {@linkplain #isSynchronizerUsageSupported ownable synchronizer usage}.
 103  * The {@link #getThreadInfo(long[], boolean, boolean)} and
 104  * {@link #dumpAllThreads} methods can be used to obtain the thread stack trace
 105  * and synchronization information including which
 106  * {@linkplain LockInfo <i>lock</i>} a thread is blocked to
 107  * acquire or waiting on and which locks the thread currently owns.
 108  * <p>
 109  * The {@code ThreadMXBean} interface provides the
 110  * {@link #findMonitorDeadlockedThreads} and
 111  * {@link #findDeadlockedThreads} methods to find deadlocks in
 112  * the running application.
 113  *
 114  * @see ManagementFactory#getPlatformMXBeans(Class)
 115  * @see <a href="../../../javax/management/package-summary.html">
 116  *      JMX Specification.</a>
 117  * @see <a href="package-summary.html#examples">
 118  *      Ways to Access MXBeans</a>
 119  *


< prev index next >