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

Comparing jsr166/src/test/tck/AbstractQueuedSynchronizerTest.java (file contents):
Revision 1.63 by jsr166, Tue Jan 23 20:44:11 2018 UTC vs.
Revision 1.68 by jsr166, Tue Aug 13 23:05:18 2019 UTC

# Line 13 | Line 13 | import java.util.ArrayList;
13   import java.util.Arrays;
14   import java.util.Collection;
15   import java.util.HashSet;
16 import java.util.concurrent.ThreadLocalRandom;
16   import java.util.concurrent.locks.AbstractQueuedSynchronizer;
17   import java.util.concurrent.locks.AbstractQueuedSynchronizer.ConditionObject;
18  
# Line 228 | Line 227 | public class AbstractQueuedSynchronizerT
227              assertTrue(c.await(timeoutMillis, MILLISECONDS));
228              break;
229          case awaitNanos:
230 <            long nanosTimeout = MILLISECONDS.toNanos(timeoutMillis);
231 <            long nanosRemaining = c.awaitNanos(nanosTimeout);
230 >            long timeoutNanos = MILLISECONDS.toNanos(timeoutMillis);
231 >            long nanosRemaining = c.awaitNanos(timeoutNanos);
232              assertTrue(nanosRemaining > 0);
233              break;
234          case awaitUntil:
# Line 256 | Line 255 | public class AbstractQueuedSynchronizerT
255                  break;
256              case awaitNanos:
257                  startTime = System.nanoTime();
258 <                long nanosTimeout = MILLISECONDS.toNanos(timeoutMillis);
259 <                long nanosRemaining = c.awaitNanos(nanosTimeout);
258 >                long timeoutNanos = MILLISECONDS.toNanos(timeoutMillis);
259 >                long nanosRemaining = c.awaitNanos(timeoutNanos);
260                  assertTrue(nanosRemaining <= 0);
261                  assertTrue(nanosRemaining > -MILLISECONDS.toNanos(LONG_DELAY_MS));
262                  assertTrue(millisElapsedSince(startTime) >= timeoutMillis);
# Line 1283 | Line 1282 | public class AbstractQueuedSynchronizerT
1282              try {
1283                  s.acquireInterruptibly(1);
1284                  shouldThrow();
1285 <            } catch (InterruptedException expected) {}
1285 >            } catch (InterruptedException success) {}
1286          };
1287          for (int i = 0; i < 2; i++) {
1288              Thread thread = new Thread(failedAcquire);
# Line 1316 | Line 1315 | public class AbstractQueuedSynchronizerT
1315  
1316          // A synchronizer only offering a choice of failure modes
1317          class Sync extends AbstractQueuedSynchronizer {
1318 <            boolean pleaseThrow;
1318 >            volatile boolean pleaseThrow;
1319              @Override protected boolean tryAcquire(int ignored) {
1320                  if (pleaseThrow) throw ex;
1321                  return false;
# Line 1338 | Line 1337 | public class AbstractQueuedSynchronizerT
1337          final Thread thread = newStartedThread(new CheckedRunnable() {
1338              public void realRun() {
1339                  try {
1340 <                    if (ThreadLocalRandom.current().nextBoolean())
1340 >                    if (randomBoolean())
1341                          s.acquire(1);
1342                      else
1343                          s.acquireShared(1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines