< prev index next >

test/jdk/com/sun/management/ThreadMXBean/ThreadCpuTimeArray.java

Print this page

  1 /*
  2  * Copyright (c) 2011, 2015, 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.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */
 23 
 24 /*
 25  * @test
 26  * @bug     6173675
 27  * @key randomness
 28  * @summary Basic test of ThreadMXBean.getThreadCpuTime(long[]) and
 29  *          getThreadUserTime(long[]).
 30  * @author  Paul Hohensee

 31  */
 32 
 33 import java.lang.management.*;
 34 
 35 public class ThreadCpuTimeArray {
 36     private static com.sun.management.ThreadMXBean mbean =
 37         (com.sun.management.ThreadMXBean)ManagementFactory.getThreadMXBean();
 38     private static boolean testFailed = false;
 39     private static boolean done = false;
 40     private static Object obj = new Object();
 41     private static final int NUM_THREADS = 10;
 42     private static Thread[] threads = new Thread[NUM_THREADS];
 43 
 44     // careful about this value
 45     private static final int DELTA = 100;
 46 
 47     public static void main(String[] argv)
 48         throws Exception {
 49 
 50         if (!mbean.isThreadCpuTimeSupported()) {

  1 /*
  2  * Copyright (c) 2011, 2024, 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.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */
 23 
 24 /*
 25  * @test
 26  * @bug     6173675
 27  * @key randomness
 28  * @summary Basic test of ThreadMXBean.getThreadCpuTime(long[]) and
 29  *          getThreadUserTime(long[]).
 30  * @author  Paul Hohensee
 31  * @requires vm.compMode != "Xcomp"
 32  */
 33 
 34 import java.lang.management.*;
 35 
 36 public class ThreadCpuTimeArray {
 37     private static com.sun.management.ThreadMXBean mbean =
 38         (com.sun.management.ThreadMXBean)ManagementFactory.getThreadMXBean();
 39     private static boolean testFailed = false;
 40     private static boolean done = false;
 41     private static Object obj = new Object();
 42     private static final int NUM_THREADS = 10;
 43     private static Thread[] threads = new Thread[NUM_THREADS];
 44 
 45     // careful about this value
 46     private static final int DELTA = 100;
 47 
 48     public static void main(String[] argv)
 49         throws Exception {
 50 
 51         if (!mbean.isThreadCpuTimeSupported()) {
< prev index next >