308 // try wait with timeout to avoid possible hanging (if LockingThread have finished execution because of uncaught exception)
309 int result = waitStateWicket.waitFor(60000);
310
311 if (result != 0) {
312 throw new TestBug("Locking thread can't reach required state (waitStateWicket wasn't unlocked)");
313 }
314
315 if (requiredState == null)
316 throw new TestBug("Required state not specified");
317
318 long startTime = System.currentTimeMillis();
319
320 // additional check to be sure that LockingThread acquired state
321 while (this.getState() != requiredState) {
322
323 // try wait with timeout to avoid possible hanging if something will go wrong
324 if ((System.currentTimeMillis() - startTime) > 60000) {
325 throw new TestBug("Locking thread can't reach required state (state: " + requiredState + " wasn't reached) in 1 minute");
326 }
327
328 yield();
329 }
330
331 requiredState = null;
332
333 Object relinquishedMonitor = getRelinquishedMonitor();
334 /*
335 * Changing thread state and release of lock is not single/atomic operation.
336 * As result there is a potential race when thread state (LockingThread) has
337 * been changed but the lock has not been released yet. To avoid this current
338 * thread is trying to acquire the same monitor, so current thread proceeds
339 * execution only when monitor has been really relinquished by LockingThread.
340 */
341 if (relinquishedMonitor != null) {
342 synchronized (relinquishedMonitor) {
343 }
344 }
345 }
346
347 // LockingThread acquired required state
348 private void ready() {
|
308 // try wait with timeout to avoid possible hanging (if LockingThread have finished execution because of uncaught exception)
309 int result = waitStateWicket.waitFor(60000);
310
311 if (result != 0) {
312 throw new TestBug("Locking thread can't reach required state (waitStateWicket wasn't unlocked)");
313 }
314
315 if (requiredState == null)
316 throw new TestBug("Required state not specified");
317
318 long startTime = System.currentTimeMillis();
319
320 // additional check to be sure that LockingThread acquired state
321 while (this.getState() != requiredState) {
322
323 // try wait with timeout to avoid possible hanging if something will go wrong
324 if ((System.currentTimeMillis() - startTime) > 60000) {
325 throw new TestBug("Locking thread can't reach required state (state: " + requiredState + " wasn't reached) in 1 minute");
326 }
327
328 Thread.yield();
329 }
330
331 requiredState = null;
332
333 Object relinquishedMonitor = getRelinquishedMonitor();
334 /*
335 * Changing thread state and release of lock is not single/atomic operation.
336 * As result there is a potential race when thread state (LockingThread) has
337 * been changed but the lock has not been released yet. To avoid this current
338 * thread is trying to acquire the same monitor, so current thread proceeds
339 * execution only when monitor has been really relinquished by LockingThread.
340 */
341 if (relinquishedMonitor != null) {
342 synchronized (relinquishedMonitor) {
343 }
344 }
345 }
346
347 // LockingThread acquired required state
348 private void ready() {
|