256 |
|
public void testParkTimesOut(final ParkMethod parkMethod) { |
257 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
258 |
|
public void realRun() { |
259 |
< |
for (;;) { |
259 |
> |
for (int tries = MAX_SPURIOUS_WAKEUPS; tries-->0; ) { |
260 |
|
long startTime = System.nanoTime(); |
261 |
|
parkMethod.park(timeoutMillis()); |
262 |
|
// park may return spuriously |
263 |
|
if (millisElapsedSince(startTime) >= timeoutMillis()) |
264 |
|
return; |
265 |
|
} |
266 |
+ |
fail("too many consecutive spurious wakeups?"); |
267 |
|
}}); |
268 |
|
|
269 |
|
awaitTermination(t); |