1 /*
2 * Copyright (c) 2003, 2004, 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 4530538
27 * @summary Basic unit test of mbean.getThreadCount()
28 * mbean.getTotalStartedThreadCount()
29 * mbean.getPeakThreadCount()
30 * mbean.getDaemonThreadCount()
31 * @author Alexei Guibadoulline
32 *
33 * @run main ThreadCounts
34 */
35
36 import java.lang.management.*;
37
38 public class ThreadCounts {
39 final static int DAEMON_THREADS = 21;
40 final static int USER_THREADS_1 = 11;
41 final static int USER_THREADS_2 = 9;
42 final static int USER_THREADS = USER_THREADS_1 + USER_THREADS_2;
43 final static int ALL_THREADS = DAEMON_THREADS + USER_THREADS;
44 private static volatile boolean live[] = new boolean[ALL_THREADS];
45 private ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
46 private static boolean testFailed = false;
47
48 // barrier for threads communication
49 private static Barrier barrier = new Barrier(DAEMON_THREADS);
50
51 public static void main(String argv[]) {
52 ThreadCounts test = new ThreadCounts();
|
1 /*
2 * Copyright (c) 2003, 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 4530538
27 * @summary Basic unit test of mbean.getThreadCount()
28 * mbean.getTotalStartedThreadCount()
29 * mbean.getPeakThreadCount()
30 * mbean.getDaemonThreadCount()
31 * @author Alexei Guibadoulline
32 *
33 * @modules java.management
34 * @run main ThreadCounts
35 */
36
37 import java.lang.management.*;
38
39 public class ThreadCounts {
40 final static int DAEMON_THREADS = 21;
41 final static int USER_THREADS_1 = 11;
42 final static int USER_THREADS_2 = 9;
43 final static int USER_THREADS = USER_THREADS_1 + USER_THREADS_2;
44 final static int ALL_THREADS = DAEMON_THREADS + USER_THREADS;
45 private static volatile boolean live[] = new boolean[ALL_THREADS];
46 private ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
47 private static boolean testFailed = false;
48
49 // barrier for threads communication
50 private static Barrier barrier = new Barrier(DAEMON_THREADS);
51
52 public static void main(String argv[]) {
53 ThreadCounts test = new ThreadCounts();
|