< prev index next >

test/jdk/jdk/jfr/event/runtime/TestJavaThreadStatisticsEventBean.java

Print this page
rev 51054 : imported patch 9000013-aixDisableJFR-requires.patch


  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 jdk.jfr.event.runtime;
  27 
  28 import static jdk.test.lib.Asserts.assertTrue;
  29 
  30 import java.lang.management.ManagementFactory;
  31 import java.lang.management.ThreadMXBean;
  32 import java.time.Duration;
  33 import java.util.List;
  34 
  35 import jdk.jfr.Recording;
  36 import jdk.jfr.consumer.RecordedEvent;
  37 import jdk.test.lib.jfr.EventNames;
  38 import jdk.test.lib.jfr.Events;
  39 
  40 /*
  41  * @test
  42  * @key jfr

  43  * @library /test/lib
  44  *
  45  * @run main/othervm jdk.jfr.event.runtime.TestJavaThreadStatisticsEventBean
  46  */
  47 public class TestJavaThreadStatisticsEventBean {
  48     private final static String EVENT_NAME = EventNames.JavaThreadStatistics;
  49 
  50     // Compare JFR thread counts to ThreadMXBean counts
  51     public static void main(String[] args) throws Throwable {
  52         long mxDaemonCount = -1;
  53         long mxActiveCount = -1;
  54 
  55         // Loop until we are sure no threads were started during the recording.
  56         Recording recording = null;
  57         ThreadMXBean mxBean = ManagementFactory.getThreadMXBean();
  58         long totalCountBefore = -1;
  59         while (totalCountBefore != mxBean.getTotalStartedThreadCount()) {
  60             recording = new Recording();
  61             recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(10));
  62             totalCountBefore = mxBean.getTotalStartedThreadCount();




  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 jdk.jfr.event.runtime;
  27 
  28 import static jdk.test.lib.Asserts.assertTrue;
  29 
  30 import java.lang.management.ManagementFactory;
  31 import java.lang.management.ThreadMXBean;
  32 import java.time.Duration;
  33 import java.util.List;
  34 
  35 import jdk.jfr.Recording;
  36 import jdk.jfr.consumer.RecordedEvent;
  37 import jdk.test.lib.jfr.EventNames;
  38 import jdk.test.lib.jfr.Events;
  39 
  40 /**
  41  * @test
  42  * @key jfr
  43  * @requires vm.hasJFR
  44  * @library /test/lib
  45  *
  46  * @run main/othervm jdk.jfr.event.runtime.TestJavaThreadStatisticsEventBean
  47  */
  48 public class TestJavaThreadStatisticsEventBean {
  49     private final static String EVENT_NAME = EventNames.JavaThreadStatistics;
  50 
  51     // Compare JFR thread counts to ThreadMXBean counts
  52     public static void main(String[] args) throws Throwable {
  53         long mxDaemonCount = -1;
  54         long mxActiveCount = -1;
  55 
  56         // Loop until we are sure no threads were started during the recording.
  57         Recording recording = null;
  58         ThreadMXBean mxBean = ManagementFactory.getThreadMXBean();
  59         long totalCountBefore = -1;
  60         while (totalCountBefore != mxBean.getTotalStartedThreadCount()) {
  61             recording = new Recording();
  62             recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(10));
  63             totalCountBefore = mxBean.getTotalStartedThreadCount();


< prev index next >