1 /*
2 * Copyright (c) 2005, 2013, 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 5086470 6358247
27 * @summary Basic Test for ThreadInfo.getLockedMonitors()
28 * - a stack frame acquires no monitor
29 * - a stack frame acquires one or more monitors
30 * - a stack frame blocks on Object.wait
31 * and the monitor waiting is not locked.
32 * LockingThread is the class that creates threads
33 * and do the checking.
34 *
35 * @author Mandy Chung
36 *
37 * @build Barrier
38 * @build LockingThread
39 * @build ThreadDump
40 * @run main/othervm LockedMonitors
41 */
42
43 import java.lang.management.*;
44 import java.util.*;
45
46 public class LockedMonitors {
47 public static void main(String[] argv) throws Exception {
48 ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
49 if (!mbean.isObjectMonitorUsageSupported()) {
50 System.out.println("Monitoring of object monitor usage is not supported");
51 return;
52 }
53
54 // Start the thread and print the thread dump
55 LockingThread.startLockingThreads();
56 ThreadDump.threadDump();
|
1 /*
2 * Copyright (c) 2005, 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 5086470 6358247
27 * @summary Basic Test for ThreadInfo.getLockedMonitors()
28 * - a stack frame acquires no monitor
29 * - a stack frame acquires one or more monitors
30 * - a stack frame blocks on Object.wait
31 * and the monitor waiting is not locked.
32 * LockingThread is the class that creates threads
33 * and do the checking.
34 *
35 * @author Mandy Chung
36 *
37 * @modules java.management
38 * @build Barrier
39 * @build LockingThread
40 * @build ThreadDump
41 * @run main/othervm LockedMonitors
42 */
43
44 import java.lang.management.*;
45 import java.util.*;
46
47 public class LockedMonitors {
48 public static void main(String[] argv) throws Exception {
49 ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
50 if (!mbean.isObjectMonitorUsageSupported()) {
51 System.out.println("Monitoring of object monitor usage is not supported");
52 return;
53 }
54
55 // Start the thread and print the thread dump
56 LockingThread.startLockingThreads();
57 ThreadDump.threadDump();
|