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 4530538
27 * @summary Basic test of ThreadMXBean.getThreadCpuTime and
28 * getCurrentThreadCpuTime.
29 * @author Mandy Chung
30 * @modules java.management
31 */
32
33 import java.lang.management.*;
34
35 public class ThreadCpuTime {
36 private static ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
37 private static boolean testFailed = false;
38 private static boolean done = false;
39 private static Object obj = new Object();
40 private static final int NUM_THREADS = 10;
41 private static Thread[] threads = new Thread[NUM_THREADS];
42 private static long[] times = new long[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 if (!mbean.isCurrentThreadCpuTimeSupported()) {
50 return;
|
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 4530538
27 * @summary Basic test of ThreadMXBean.getThreadCpuTime and
28 * getCurrentThreadCpuTime.
29 * @author Mandy Chung
30 */
31
32 import java.lang.management.*;
33
34 public class ThreadCpuTime {
35 private static ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
36 private static boolean testFailed = false;
37 private static boolean done = false;
38 private static Object obj = new Object();
39 private static final int NUM_THREADS = 10;
40 private static Thread[] threads = new Thread[NUM_THREADS];
41 private static long[] times = new long[NUM_THREADS];
42
43 // careful about this value
44 private static final int DELTA = 100;
45
46 public static void main(String[] argv)
47 throws Exception {
48 if (!mbean.isCurrentThreadCpuTimeSupported()) {
49 return;
|