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.62 by dl, Sun Jan 7 23:05:44 2018 UTC vs.
Revision 1.67 by jsr166, Tue Aug 13 03:39:46 2019 UTC

# Line 17 | Line 17 | import java.util.concurrent.ThreadLocalR
17   import java.util.concurrent.locks.AbstractQueuedSynchronizer;
18   import java.util.concurrent.locks.AbstractQueuedSynchronizer.ConditionObject;
19  
20 import junit.framework.AssertionFailedError;
20   import junit.framework.Test;
21   import junit.framework.TestSuite;
22  
# Line 145 | Line 144 | public class AbstractQueuedSynchronizerT
144          long startTime = System.nanoTime();
145          while (!sync.isQueued(t)) {
146              if (millisElapsedSince(startTime) > LONG_DELAY_MS)
147 <                throw new AssertionFailedError("timed out");
147 >                throw new AssertionError("timed out");
148              Thread.yield();
149          }
150          assertTrue(t.isAlive());
# Line 229 | Line 228 | public class AbstractQueuedSynchronizerT
228              assertTrue(c.await(timeoutMillis, MILLISECONDS));
229              break;
230          case awaitNanos:
231 <            long nanosTimeout = MILLISECONDS.toNanos(timeoutMillis);
232 <            long nanosRemaining = c.awaitNanos(nanosTimeout);
231 >            long timeoutNanos = MILLISECONDS.toNanos(timeoutMillis);
232 >            long nanosRemaining = c.awaitNanos(timeoutNanos);
233              assertTrue(nanosRemaining > 0);
234              break;
235          case awaitUntil:
# Line 257 | Line 256 | public class AbstractQueuedSynchronizerT
256                  break;
257              case awaitNanos:
258                  startTime = System.nanoTime();
259 <                long nanosTimeout = MILLISECONDS.toNanos(timeoutMillis);
260 <                long nanosRemaining = c.awaitNanos(nanosTimeout);
259 >                long timeoutNanos = MILLISECONDS.toNanos(timeoutMillis);
260 >                long nanosRemaining = c.awaitNanos(timeoutNanos);
261                  assertTrue(nanosRemaining <= 0);
262                  assertTrue(nanosRemaining > -MILLISECONDS.toNanos(LONG_DELAY_MS));
263                  assertTrue(millisElapsedSince(startTime) >= timeoutMillis);
# Line 1284 | Line 1283 | public class AbstractQueuedSynchronizerT
1283              try {
1284                  s.acquireInterruptibly(1);
1285                  shouldThrow();
1286 <            } catch (InterruptedException expected) {}
1286 >            } catch (InterruptedException success) {}
1287          };
1288          for (int i = 0; i < 2; i++) {
1289              Thread thread = new Thread(failedAcquire);
# Line 1317 | Line 1316 | public class AbstractQueuedSynchronizerT
1316  
1317          // A synchronizer only offering a choice of failure modes
1318          class Sync extends AbstractQueuedSynchronizer {
1319 <            boolean pleaseThrow;
1319 >            volatile boolean pleaseThrow;
1320              @Override protected boolean tryAcquire(int ignored) {
1321                  if (pleaseThrow) throw ex;
1322                  return false;
# Line 1339 | Line 1338 | public class AbstractQueuedSynchronizerT
1338          final Thread thread = newStartedThread(new CheckedRunnable() {
1339              public void realRun() {
1340                  try {
1341 <                    if (ThreadLocalRandom.current().nextBoolean())
1341 >                    if (randomBoolean())
1342                          s.acquire(1);
1343                      else
1344                          s.acquireShared(1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines