< prev index next >

src/java.management/share/classes/java/lang/management/ThreadInfo.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
  23  * questions.
  24  */
  25 
  26 package java.lang.management;
  27 
  28 import javax.management.openmbean.ArrayType;
  29 import javax.management.openmbean.CompositeData;
  30 import sun.management.ManagementFactoryHelper;
  31 import sun.management.ThreadInfoCompositeData;
  32 import static java.lang.Thread.State.*;
  33 
  34 /**
  35  * Thread information. {@code ThreadInfo} contains the information
  36  * about a thread including:
  37  * <h2>General thread information</h2>
  38  * <ul>
  39  *   <li>Thread ID.</li>
  40  *   <li>Name of the thread.</li>
  41  *   <li>Whether a thread is a daemon thread</li>
  42  * </ul>
  43  *
  44  * <h2>Execution information</h2>
  45  * <ul>
  46  *   <li>Thread state.</li>
  47  *   <li>The object upon which the thread is blocked due to:
  48  *       <ul>
  49  *       <li>waiting to enter a synchronization block/method, or</li>
  50  *       <li>waiting to be notified in a {@link Object#wait Object.wait} method,
  51  *           or</li>
  52  *       <li>parking due to a {@link java.util.concurrent.locks.LockSupport#park
  53  *           LockSupport.park} call.</li>
  54  *       </ul>
  55  *   </li>
  56  *   <li>The ID of the thread that owns the object
  57  *       that the thread is blocked.</li>
  58  *   <li>Stack trace of the thread.</li>
  59  *   <li>List of object monitors locked by the thread.</li>
  60  *   <li>List of <a href="LockInfo.html#OwnableSynchronizer">
  61  *       ownable synchronizers</a> locked by the thread.</li>
  62  *   <li>Thread priority</li>
  63  * </ul>
  64  *
  65  * <h3><a id="SyncStats">Synchronization Statistics</a></h3>
  66  * <ul>
  67  *   <li>The number of times that the thread has blocked for
  68  *       synchronization or waited for notification.</li>
  69  *   <li>The accumulated elapsed time that the thread has blocked
  70  *       for synchronization or waited for notification
  71  *       since {@link ThreadMXBean#setThreadContentionMonitoringEnabled
  72  *       thread contention monitoring}
  73  *       was enabled. Some Java virtual machine implementation
  74  *       may not support this.  The
  75  *       {@link ThreadMXBean#isThreadContentionMonitoringSupported()}
  76  *       method can be used to determine if a Java virtual machine
  77  *       supports this.</li>
  78  * </ul>
  79  *
  80  * <p>This thread information class is designed for use in monitoring of
  81  * the system, not for synchronization control.
  82  *
  83  * <h3>MXBean Mapping</h3>
  84  * {@code ThreadInfo} is mapped to a {@link CompositeData CompositeData}
  85  * with attributes as specified in
  86  * the {@link #from from} method.
  87  *
  88  * @see ThreadMXBean#getThreadInfo
  89  * @see ThreadMXBean#dumpAllThreads
  90  *
  91  * @author  Mandy Chung
  92  * @since   1.5
  93  */
  94 
  95 public class ThreadInfo {
  96     private String       threadName;
  97     private long         threadId;
  98     private long         blockedTime;
  99     private long         blockedCount;
 100     private long         waitedTime;
 101     private long         waitedCount;
 102     private LockInfo     lock;
 103     private String       lockName;


   1 /*
   2  * Copyright (c) 2003, 2018, 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
  23  * questions.
  24  */
  25 
  26 package java.lang.management;
  27 
  28 import javax.management.openmbean.ArrayType;
  29 import javax.management.openmbean.CompositeData;
  30 import sun.management.ManagementFactoryHelper;
  31 import sun.management.ThreadInfoCompositeData;
  32 import static java.lang.Thread.State.*;
  33 
  34 /**
  35  * Thread information. {@code ThreadInfo} contains the information
  36  * about a thread including:
  37  * <h3>General thread information</h3>
  38  * <ul>
  39  *   <li>Thread ID.</li>
  40  *   <li>Name of the thread.</li>
  41  *   <li>Whether a thread is a daemon thread</li>
  42  * </ul>
  43  *
  44  * <h3>Execution information</h3>
  45  * <ul>
  46  *   <li>Thread state.</li>
  47  *   <li>The object upon which the thread is blocked due to:
  48  *       <ul>
  49  *       <li>waiting to enter a synchronization block/method, or</li>
  50  *       <li>waiting to be notified in a {@link Object#wait Object.wait} method,
  51  *           or</li>
  52  *       <li>parking due to a {@link java.util.concurrent.locks.LockSupport#park
  53  *           LockSupport.park} call.</li>
  54  *       </ul>
  55  *   </li>
  56  *   <li>The ID of the thread that owns the object
  57  *       that the thread is blocked.</li>
  58  *   <li>Stack trace of the thread.</li>
  59  *   <li>List of object monitors locked by the thread.</li>
  60  *   <li>List of <a href="LockInfo.html#OwnableSynchronizer">
  61  *       ownable synchronizers</a> locked by the thread.</li>
  62  *   <li>Thread priority</li>
  63  * </ul>
  64  *
  65  * <h4><a id="SyncStats">Synchronization Statistics</a></h4>
  66  * <ul>
  67  *   <li>The number of times that the thread has blocked for
  68  *       synchronization or waited for notification.</li>
  69  *   <li>The accumulated elapsed time that the thread has blocked
  70  *       for synchronization or waited for notification
  71  *       since {@link ThreadMXBean#setThreadContentionMonitoringEnabled
  72  *       thread contention monitoring}
  73  *       was enabled. Some Java virtual machine implementation
  74  *       may not support this.  The
  75  *       {@link ThreadMXBean#isThreadContentionMonitoringSupported()}
  76  *       method can be used to determine if a Java virtual machine
  77  *       supports this.</li>
  78  * </ul>
  79  *
  80  * <p>This thread information class is designed for use in monitoring of
  81  * the system, not for synchronization control.
  82  *
  83  * <h4>MXBean Mapping</h4>
  84  * {@code ThreadInfo} is mapped to a {@link CompositeData CompositeData}
  85  * with attributes as specified in
  86  * the {@link #from from} method.
  87  *
  88  * @see ThreadMXBean#getThreadInfo
  89  * @see ThreadMXBean#dumpAllThreads
  90  *
  91  * @author  Mandy Chung
  92  * @since   1.5
  93  */
  94 
  95 public class ThreadInfo {
  96     private String       threadName;
  97     private long         threadId;
  98     private long         blockedTime;
  99     private long         blockedCount;
 100     private long         waitedTime;
 101     private long         waitedCount;
 102     private LockInfo     lock;
 103     private String       lockName;


< prev index next >