224 |
|
assertTrue(c.await(timeoutMillis, MILLISECONDS)); |
225 |
|
break; |
226 |
|
case awaitNanos: |
227 |
< |
long nanosTimeout = MILLISECONDS.toNanos(timeoutMillis); |
228 |
< |
long nanosRemaining = c.awaitNanos(nanosTimeout); |
227 |
> |
long timeoutNanos = MILLISECONDS.toNanos(timeoutMillis); |
228 |
> |
long nanosRemaining = c.awaitNanos(timeoutNanos); |
229 |
|
assertTrue(nanosRemaining > 0); |
230 |
|
break; |
231 |
|
case awaitUntil: |
252 |
|
break; |
253 |
|
case awaitNanos: |
254 |
|
startTime = System.nanoTime(); |
255 |
< |
long nanosTimeout = MILLISECONDS.toNanos(timeoutMillis); |
256 |
< |
long nanosRemaining = c.awaitNanos(nanosTimeout); |
255 |
> |
long timeoutNanos = MILLISECONDS.toNanos(timeoutMillis); |
256 |
> |
long nanosRemaining = c.awaitNanos(timeoutNanos); |
257 |
|
assertTrue(nanosRemaining <= 0); |
258 |
|
assertTrue(nanosRemaining > -MILLISECONDS.toNanos(LONG_DELAY_MS)); |
259 |
|
assertTrue(millisElapsedSince(startTime) >= timeoutMillis); |
1265 |
|
|
1266 |
|
// A synchronizer only offering a choice of failure modes |
1267 |
|
class Sync extends AbstractQueuedLongSynchronizer { |
1268 |
< |
boolean pleaseThrow; |
1268 |
> |
volatile boolean pleaseThrow; |
1269 |
|
@Override protected boolean tryAcquire(long ignored) { |
1270 |
|
if (pleaseThrow) throw ex; |
1271 |
|
return false; |
1287 |
|
final Thread thread = newStartedThread(new CheckedRunnable() { |
1288 |
|
public void realRun() { |
1289 |
|
try { |
1290 |
< |
if (ThreadLocalRandom.current().nextBoolean()) |
1290 |
> |
if (randomBoolean()) |
1291 |
|
s.acquire(1); |
1292 |
|
else |
1293 |
|
s.acquireShared(1); |