ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/SemaphoreTest.java
(Generate patch)

Comparing jsr166/src/test/tck/SemaphoreTest.java (file contents):
Revision 1.39 by jsr166, Sun May 14 03:31:53 2017 UTC vs.
Revision 1.42 by jsr166, Mon May 29 19:15:03 2017 UTC

# Line 195 | Line 195 | public class SemaphoreTest extends JSR16
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)); }
# Line 208 | Line 207 | public class SemaphoreTest extends JSR16
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)); }
# Line 273 | Line 271 | public class SemaphoreTest extends JSR16
271              assertThreadBlocks(t, acquirer.parkedState());
272              t.interrupt();
273          }
274 <        
274 >
275          awaitTermination(t);
276      }
277  
# Line 610 | Line 608 | public class SemaphoreTest extends JSR16
608          Thread t2 = newStartedThread(new CheckedRunnable() {
609              public void realRun() throws InterruptedException {
610                  // Will fail, even though 1 permit is available
611 <                assertFalse(s.tryAcquire(0L, MILLISECONDS));
612 <                assertFalse(s.tryAcquire(1, 0L, MILLISECONDS));
611 >                assertFalse(
612 >                    s.tryAcquire(randomExpiredTimeout(), randomTimeUnit()));
613 >                assertFalse(
614 >                    s.tryAcquire(1, randomExpiredTimeout(), randomTimeUnit()));
615  
616                  // untimed tryAcquire will barge and succeed
617                  assertTrue(s.tryAcquire());

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines