--- jsr166/src/test/tck/AbstractQueuedSynchronizerTest.java 2018/06/13 18:36:31 1.64 +++ jsr166/src/test/tck/AbstractQueuedSynchronizerTest.java 2019/08/13 23:05:18 1.68 @@ -13,7 +13,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; -import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.locks.AbstractQueuedSynchronizer; import java.util.concurrent.locks.AbstractQueuedSynchronizer.ConditionObject; @@ -1283,7 +1282,7 @@ public class AbstractQueuedSynchronizerT try { s.acquireInterruptibly(1); shouldThrow(); - } catch (InterruptedException expected) {} + } catch (InterruptedException success) {} }; for (int i = 0; i < 2; i++) { Thread thread = new Thread(failedAcquire); @@ -1316,7 +1315,7 @@ public class AbstractQueuedSynchronizerT // A synchronizer only offering a choice of failure modes class Sync extends AbstractQueuedSynchronizer { - boolean pleaseThrow; + volatile boolean pleaseThrow; @Override protected boolean tryAcquire(int ignored) { if (pleaseThrow) throw ex; return false; @@ -1338,7 +1337,7 @@ public class AbstractQueuedSynchronizerT final Thread thread = newStartedThread(new CheckedRunnable() { public void realRun() { try { - if (ThreadLocalRandom.current().nextBoolean()) + if (randomBoolean()) s.acquire(1); else s.acquireShared(1);