186 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
187 |
|
public void realRun() { |
188 |
|
pleaseInterrupt.countDown(); |
189 |
< |
do { |
189 |
> |
for (int tries = MAX_SPURIOUS_WAKEUPS; tries-->0; ) { |
190 |
|
parkMethod.park(); |
191 |
< |
// park may return spuriously |
192 |
< |
} while (! Thread.interrupted()); |
191 |
> |
if (Thread.interrupted()) |
192 |
> |
return; |
193 |
> |
} |
194 |
> |
fail("too many consecutive spurious wakeups?"); |
195 |
|
}}); |
196 |
|
|
197 |
|
await(pleaseInterrupt); |
261 |
|
for (int tries = MAX_SPURIOUS_WAKEUPS; tries-->0; ) { |
262 |
|
long startTime = System.nanoTime(); |
263 |
|
parkMethod.park(timeoutMillis()); |
262 |
– |
// park may return spuriously |
264 |
|
if (millisElapsedSince(startTime) >= timeoutMillis()) |
265 |
|
return; |
266 |
|
} |
298 |
|
public void realRun() { |
299 |
|
Thread t = Thread.currentThread(); |
300 |
|
started.countDown(); |
301 |
< |
do { |
301 |
> |
for (int tries = MAX_SPURIOUS_WAKEUPS; tries-->0; ) { |
302 |
|
assertNull(LockSupport.getBlocker(t)); |
303 |
|
parkMethod.park(); |
304 |
|
assertNull(LockSupport.getBlocker(t)); |
305 |
< |
// park may return spuriously |
306 |
< |
} while (! Thread.interrupted()); |
305 |
> |
if (Thread.interrupted()) |
306 |
> |
return; |
307 |
> |
} |
308 |
> |
fail("too many consecutive spurious wakeups?"); |
309 |
|
}}); |
310 |
|
|
311 |
|
long startTime = System.nanoTime(); |
321 |
|
assertNull(x); // ok |
322 |
|
if (millisElapsedSince(startTime) > LONG_DELAY_MS) |
323 |
|
fail("timed out"); |
324 |
+ |
if (t.getState() == Thread.State.TERMINATED) |
325 |
+ |
break; |
326 |
|
Thread.yield(); |
327 |
|
} |
328 |
|
} |