annotate agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java @ 12226:7944aba7ba41

8015107: NPG: Use consistent naming for metaspace concepts Reviewed-by: coleenp, mgerdin, hseigel
author ehelin
date Mon, 12 Aug 2013 17:37:02 +0200
parents 39432a1cefdd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.runtime;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.types.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.runtime.solaris_sparc.SolarisSPARCJavaThreadPDAccess;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.runtime.solaris_x86.SolarisX86JavaThreadPDAccess;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.runtime.solaris_amd64.SolarisAMD64JavaThreadPDAccess;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.runtime.win32_amd64.Win32AMD64JavaThreadPDAccess;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 import sun.jvm.hotspot.runtime.win32_x86.Win32X86JavaThreadPDAccess;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 import sun.jvm.hotspot.runtime.linux_x86.LinuxX86JavaThreadPDAccess;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 import sun.jvm.hotspot.runtime.linux_amd64.LinuxAMD64JavaThreadPDAccess;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 import sun.jvm.hotspot.runtime.linux_sparc.LinuxSPARCJavaThreadPDAccess;
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 2195
diff changeset
38 import sun.jvm.hotspot.runtime.bsd_x86.BsdX86JavaThreadPDAccess;
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 2195
diff changeset
39 import sun.jvm.hotspot.runtime.bsd_amd64.BsdAMD64JavaThreadPDAccess;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
40 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 public class Threads {
a61af66fc99e Initial load
duke
parents:
diff changeset
43 private static JavaThreadFactory threadFactory;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 private static AddressField threadListField;
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
45 private static CIntegerField numOfThreadsField;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
46 private static VirtualConstructor virtualConstructor;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 private static JavaThreadPDAccess access;
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 VM.registerVMInitializedObserver(new Observer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 public void update(Observable o, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 initialize(VM.getVM().getTypeDataBase());
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
a61af66fc99e Initial load
duke
parents:
diff changeset
54 });
a61af66fc99e Initial load
duke
parents:
diff changeset
55 }
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 private static synchronized void initialize(TypeDataBase db) {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 Type type = db.lookupType("Threads");
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 threadListField = type.getAddressField("_thread_list");
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
61 numOfThreadsField = type.getCIntegerField("_number_of_threads");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // Instantiate appropriate platform-specific JavaThreadFactory
a61af66fc99e Initial load
duke
parents:
diff changeset
64 String os = VM.getVM().getOS();
a61af66fc99e Initial load
duke
parents:
diff changeset
65 String cpu = VM.getVM().getCPU();
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 access = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // FIXME: find the platform specific PD class by reflection?
a61af66fc99e Initial load
duke
parents:
diff changeset
69 if (os.equals("solaris")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 if (cpu.equals("sparc")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 access = new SolarisSPARCJavaThreadPDAccess();
a61af66fc99e Initial load
duke
parents:
diff changeset
72 } else if (cpu.equals("x86")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 access = new SolarisX86JavaThreadPDAccess();
a61af66fc99e Initial load
duke
parents:
diff changeset
74 } else if (cpu.equals("amd64")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 access = new SolarisAMD64JavaThreadPDAccess();
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77 } else if (os.equals("win32")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 if (cpu.equals("x86")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
79 access = new Win32X86JavaThreadPDAccess();
a61af66fc99e Initial load
duke
parents:
diff changeset
80 } else if (cpu.equals("amd64")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 access = new Win32AMD64JavaThreadPDAccess();
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }
a61af66fc99e Initial load
duke
parents:
diff changeset
83 } else if (os.equals("linux")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 if (cpu.equals("x86")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 access = new LinuxX86JavaThreadPDAccess();
a61af66fc99e Initial load
duke
parents:
diff changeset
86 } else if (cpu.equals("amd64")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 access = new LinuxAMD64JavaThreadPDAccess();
a61af66fc99e Initial load
duke
parents:
diff changeset
88 } else if (cpu.equals("sparc")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 access = new LinuxSPARCJavaThreadPDAccess();
6641
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
90 } else {
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
91 try {
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
92 access = (JavaThreadPDAccess)
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
93 Class.forName("sun.jvm.hotspot.runtime.linux_" +
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
94 cpu.toLowerCase() + ".Linux" + cpu.toUpperCase() +
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
95 "JavaThreadPDAccess").newInstance();
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
96 } catch (Exception e) {
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
97 throw new RuntimeException("OS/CPU combination " + os + "/" + cpu +
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
98 " not yet supported");
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
99 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 2195
diff changeset
101 } else if (os.equals("bsd")) {
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 2195
diff changeset
102 if (cpu.equals("x86")) {
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 2195
diff changeset
103 access = new BsdX86JavaThreadPDAccess();
6073
78d2ae5ab35b 7163117: Agent can't connect to process on Mac OSX
nloodin
parents: 3960
diff changeset
104 } else if (cpu.equals("amd64") || cpu.equals("x86_64")) {
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 2195
diff changeset
105 access = new BsdAMD64JavaThreadPDAccess();
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 2195
diff changeset
106 }
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
107 } else if (os.equals("darwin")) {
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
108 if (cpu.equals("amd64") || cpu.equals("x86_64")) {
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
109 access = new BsdAMD64JavaThreadPDAccess();
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
110 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 if (access == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 throw new RuntimeException("OS/CPU combination " + os + "/" + cpu +
a61af66fc99e Initial load
duke
parents:
diff changeset
115 " not yet supported");
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 virtualConstructor = new VirtualConstructor(db);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // Add mappings for all known thread types
a61af66fc99e Initial load
duke
parents:
diff changeset
120 virtualConstructor.addMapping("JavaThread", JavaThread.class);
a61af66fc99e Initial load
duke
parents:
diff changeset
121 if (!VM.getVM().isCore()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 virtualConstructor.addMapping("CompilerThread", CompilerThread.class);
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // for now, use JavaThread itself. fix it later with appropriate class if needed
a61af66fc99e Initial load
duke
parents:
diff changeset
125 virtualConstructor.addMapping("SurrogateLockerThread", JavaThread.class);
a61af66fc99e Initial load
duke
parents:
diff changeset
126 virtualConstructor.addMapping("JvmtiAgentThread", JvmtiAgentThread.class);
2195
bf8517f4e4d0 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 1552
diff changeset
127 virtualConstructor.addMapping("ServiceThread", ServiceThread.class);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 public Threads() {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 /** NOTE: this returns objects of type JavaThread, CompilerThread,
2195
bf8517f4e4d0 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 1552
diff changeset
134 JvmtiAgentThread, and ServiceThread.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
135 The latter four are subclasses of the former. Most operations
a61af66fc99e Initial load
duke
parents:
diff changeset
136 (fetching the top frame, etc.) are only allowed to be performed on
a61af66fc99e Initial load
duke
parents:
diff changeset
137 a "pure" JavaThread. For this reason, {@link
a61af66fc99e Initial load
duke
parents:
diff changeset
138 sun.jvm.hotspot.runtime.JavaThread#isJavaThread} has been
a61af66fc99e Initial load
duke
parents:
diff changeset
139 changed from the definition in the VM (which returns true for
a61af66fc99e Initial load
duke
parents:
diff changeset
140 all of these thread types) to return true for JavaThreads and
a61af66fc99e Initial load
duke
parents:
diff changeset
141 false for the three subclasses. FIXME: should reconsider the
a61af66fc99e Initial load
duke
parents:
diff changeset
142 inheritance hierarchy; see {@link
a61af66fc99e Initial load
duke
parents:
diff changeset
143 sun.jvm.hotspot.runtime.JavaThread#isJavaThread}. */
a61af66fc99e Initial load
duke
parents:
diff changeset
144 public JavaThread first() {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 Address threadAddr = threadListField.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
146 if (threadAddr == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 return createJavaThreadWrapper(threadAddr);
a61af66fc99e Initial load
duke
parents:
diff changeset
151 }
a61af66fc99e Initial load
duke
parents:
diff changeset
152
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
153 public int getNumberOfThreads() {
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
154 return (int) numOfThreadsField.getValue();
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
155 }
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
156
0
a61af66fc99e Initial load
duke
parents:
diff changeset
157 /** Routine for instantiating appropriately-typed wrapper for a
a61af66fc99e Initial load
duke
parents:
diff changeset
158 JavaThread. Currently needs to be public for OopUtilities to
a61af66fc99e Initial load
duke
parents:
diff changeset
159 access it. */
a61af66fc99e Initial load
duke
parents:
diff changeset
160 public JavaThread createJavaThreadWrapper(Address threadAddr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
161 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 JavaThread thread = (JavaThread)virtualConstructor.instantiateWrapperFor(threadAddr);
a61af66fc99e Initial load
duke
parents:
diff changeset
163 thread.setThreadPDAccess(access);
a61af66fc99e Initial load
duke
parents:
diff changeset
164 return thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
165 } catch (Exception e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 throw new RuntimeException("Unable to deduce type of thread from address " + threadAddr +
2195
bf8517f4e4d0 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 1552
diff changeset
167 " (expected type JavaThread, CompilerThread, ServiceThread, JvmtiAgentThread, or SurrogateLockerThread)", e);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
169 }
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 /** Memory operations */
a61af66fc99e Initial load
duke
parents:
diff changeset
172 public void oopsDo(AddressVisitor oopVisitor) {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // FIXME: add more of VM functionality
a61af66fc99e Initial load
duke
parents:
diff changeset
174 for (JavaThread thread = first(); thread != null; thread = thread.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 thread.oopsDo(oopVisitor);
a61af66fc99e Initial load
duke
parents:
diff changeset
176 }
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
178
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // refer to Threads::owning_thread_from_monitor_owner
a61af66fc99e Initial load
duke
parents:
diff changeset
180 public JavaThread owningThreadFromMonitor(Address o) {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 if (o == null) return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
182 for (JavaThread thread = first(); thread != null; thread = thread.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 if (o.equals(thread.threadObjectAddress())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 return thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 for (JavaThread thread = first(); thread != null; thread = thread.next()) {
702
b9fba36710f2 6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents: 0
diff changeset
189 if (thread.isLockOwned(o))
b9fba36710f2 6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents: 0
diff changeset
190 return thread;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
191 }
702
b9fba36710f2 6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents: 0
diff changeset
192 return null;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 public JavaThread owningThreadFromMonitor(ObjectMonitor monitor) {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 return owningThreadFromMonitor(monitor.owner());
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // refer to Threads::get_pending_threads
a61af66fc99e Initial load
duke
parents:
diff changeset
200 // Get list of Java threads that are waiting to enter the specified monitor.
a61af66fc99e Initial load
duke
parents:
diff changeset
201 public List getPendingThreads(ObjectMonitor monitor) {
a61af66fc99e Initial load
duke
parents:
diff changeset
202 List pendingThreads = new ArrayList();
a61af66fc99e Initial load
duke
parents:
diff changeset
203 for (JavaThread thread = first(); thread != null; thread = thread.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
204 if (thread.isCompilerThread()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
206 }
a61af66fc99e Initial load
duke
parents:
diff changeset
207 ObjectMonitor pending = thread.getCurrentPendingMonitor();
a61af66fc99e Initial load
duke
parents:
diff changeset
208 if (monitor.equals(pending)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
209 pendingThreads.add(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
210 }
a61af66fc99e Initial load
duke
parents:
diff changeset
211 }
a61af66fc99e Initial load
duke
parents:
diff changeset
212 return pendingThreads;
a61af66fc99e Initial load
duke
parents:
diff changeset
213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
214
a61af66fc99e Initial load
duke
parents:
diff changeset
215 // Get list of Java threads that have called Object.wait on the specified monitor.
a61af66fc99e Initial load
duke
parents:
diff changeset
216 public List getWaitingThreads(ObjectMonitor monitor) {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 List pendingThreads = new ArrayList();
a61af66fc99e Initial load
duke
parents:
diff changeset
218 for (JavaThread thread = first(); thread != null; thread = thread.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 ObjectMonitor waiting = thread.getCurrentWaitingMonitor();
a61af66fc99e Initial load
duke
parents:
diff changeset
220 if (monitor.equals(waiting)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
221 pendingThreads.add(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
222 }
a61af66fc99e Initial load
duke
parents:
diff changeset
223 }
a61af66fc99e Initial load
duke
parents:
diff changeset
224 return pendingThreads;
a61af66fc99e Initial load
duke
parents:
diff changeset
225 }
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // FIXME: add other accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
228 }