1 /* |
1 /* |
2 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. |
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. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
107 ThreadInfo ti = mbean.getThreadInfo(tid); |
107 ThreadInfo ti = mbean.getThreadInfo(tid); |
108 String lockName = null; |
108 String lockName = null; |
109 synchronized(lock1) { |
109 synchronized(lock1) { |
110 p.arriveAndAwaitAdvance(); // phase[1] |
110 p.arriveAndAwaitAdvance(); // phase[1] |
111 waitForThreadState(lt, Thread.State.BLOCKED); |
111 waitForThreadState(lt, Thread.State.BLOCKED); |
112 lockName = mbean.getThreadInfo(tid).getLockName(); |
112 do { |
|
113 lockName = mbean.getThreadInfo(tid).getLockName(); |
|
114 } while (lockName == null); |
113 } |
115 } |
114 |
116 |
115 p.arriveAndAwaitAdvance(); // phase[2] |
117 p.arriveAndAwaitAdvance(); // phase[2] |
116 testBlocked(ti, () -> mbean.getThreadInfo(tid), lockName, lock1); |
118 testBlocked(ti, () -> mbean.getThreadInfo(tid), lockName, lock1); |
117 p.arriveAndDeregister(); // phase[3] |
119 p.arriveAndDeregister(); // phase[3] |
157 ThreadInfo ti = mbean.getThreadInfo(tid); |
159 ThreadInfo ti = mbean.getThreadInfo(tid); |
158 String lockName = null; |
160 String lockName = null; |
159 synchronized(lock1) { |
161 synchronized(lock1) { |
160 p.arriveAndAwaitAdvance(); // phase[1] |
162 p.arriveAndAwaitAdvance(); // phase[1] |
161 waitForThreadState(lt, Thread.State.BLOCKED); |
163 waitForThreadState(lt, Thread.State.BLOCKED); |
162 lockName = mbean.getThreadInfo(tid).getLockName(); |
164 do { |
|
165 lockName = mbean.getThreadInfo(tid).getLockName(); |
|
166 } while (lockName == null); |
163 } |
167 } |
164 p.arriveAndAwaitAdvance(); // phase[2] |
168 p.arriveAndAwaitAdvance(); // phase[2] |
165 |
169 |
166 ti = testBlocked(ti, () -> mbean.getThreadInfo(tid), lockName, lock1); |
170 ti = testBlocked(ti, () -> mbean.getThreadInfo(tid), lockName, lock1); |
167 |
171 |
168 synchronized(lock2) { |
172 synchronized(lock2) { |
169 p.arriveAndAwaitAdvance(); // phase [3] |
173 p.arriveAndAwaitAdvance(); // phase [3] |
170 waitForThreadState(lt, Thread.State.BLOCKED); |
174 waitForThreadState(lt, Thread.State.BLOCKED); |
171 lockName = mbean.getThreadInfo(tid).getLockName(); |
175 do { |
|
176 lockName = mbean.getThreadInfo(tid).getLockName(); |
|
177 } while (lockName == null); |
172 } |
178 } |
173 p.arriveAndAwaitAdvance(); // phase [4] |
179 p.arriveAndAwaitAdvance(); // phase [4] |
174 testBlocked(ti, () -> mbean.getThreadInfo(tid), lockName, lock2); |
180 testBlocked(ti, () -> mbean.getThreadInfo(tid), lockName, lock2); |
175 p.arriveAndDeregister(); |
181 p.arriveAndDeregister(); |
176 |
182 |