195 |
|
* timed tryAcquire times out |
196 |
|
*/ |
197 |
|
public void testTryAcquire_timeout() { |
198 |
< |
final ThreadLocalRandom rnd = ThreadLocalRandom.current(); |
199 |
< |
final boolean fair = rnd.nextBoolean(); |
198 |
> |
final boolean fair = ThreadLocalRandom.current().nextBoolean(); |
199 |
|
final Semaphore s = new Semaphore(0, fair); |
200 |
|
final long startTime = System.nanoTime(); |
201 |
|
try { assertFalse(s.tryAcquire(timeoutMillis(), MILLISECONDS)); } |
207 |
|
* timed tryAcquire(N) times out |
208 |
|
*/ |
209 |
|
public void testTryAcquireN_timeout() { |
210 |
< |
final ThreadLocalRandom rnd = ThreadLocalRandom.current(); |
212 |
< |
final boolean fair = rnd.nextBoolean(); |
210 |
> |
final boolean fair = ThreadLocalRandom.current().nextBoolean(); |
211 |
|
final Semaphore s = new Semaphore(2, fair); |
212 |
|
final long startTime = System.nanoTime(); |
213 |
|
try { assertFalse(s.tryAcquire(3, timeoutMillis(), MILLISECONDS)); } |