--- jsr166/src/test/tck/AbstractQueuedSynchronizerTest.java 2003/12/30 15:48:38 1.5 +++ jsr166/src/test/tck/AbstractQueuedSynchronizerTest.java 2003/12/31 21:30:08 1.6 @@ -30,31 +30,33 @@ public class AbstractQueuedSynchronizerT */ static class Mutex implements Lock, java.io.Serializable { private static class Sync extends AbstractQueuedSynchronizer { - public int acquireExclusiveState(boolean isQueued, int acquires) { + boolean isLocked() { return getState() == 1; } + + public boolean tryAcquireExclusiveState(boolean isQueued, int acquires) { assert acquires == 1; // Does not use multiple acquires - return compareAndSet(0, 1)? 0 : -1; + return compareAndSetState(0, 1); } public boolean releaseExclusiveState(int releases) { - set(0); + setState(0); return true; } public void checkConditionAccess(Thread thread, boolean waiting) { - if (get() == 0) throw new IllegalMonitorStateException(); + if (getState() == 0) throw new IllegalMonitorStateException(); } Condition newCondition() { return new ConditionObject(); } private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject(); - set(0); // reset to unlocked state + setState(0); // reset to unlocked state } } private final Sync sync = new Sync(); public boolean tryLock() { - return sync.acquireExclusiveState(false, 1) >= 0; + return sync.tryAcquireExclusiveState(false, 1); } public void lock() { sync.acquireExclusiveUninterruptibly(1); @@ -67,7 +69,7 @@ public class AbstractQueuedSynchronizerT } public void unlock() { sync.releaseExclusive(1); } public Condition newCondition() { return sync.newCondition(); } - public boolean isLocked() { return sync.get() != 0; } + public boolean isLocked() { return sync.isLocked(); } public boolean hasQueuedThreads() { return sync.hasQueuedThreads(); } }