--- jsr166/src/test/tck/AbstractQueuedSynchronizerTest.java 2003/12/29 01:18:40 1.2 +++ jsr166/src/test/tck/AbstractQueuedSynchronizerTest.java 2003/12/30 15:48:38 1.5 @@ -30,42 +30,34 @@ public class AbstractQueuedSynchronizerT */ static class Mutex implements Lock, java.io.Serializable { private static class Sync extends AbstractQueuedSynchronizer { - public int acquireExclusiveState(boolean isQueued, int acquires, Thread current) { + public int acquireExclusiveState(boolean isQueued, int acquires) { assert acquires == 1; // Does not use multiple acquires - return state().compareAndSet(0, 1)? 0 : -1; + return compareAndSet(0, 1)? 0 : -1; } public boolean releaseExclusiveState(int releases) { - state().set(0); + set(0); return true; } - public int acquireSharedState(boolean isQueued, int acquires, Thread current) { - throw new UnsupportedOperationException(); - } - - public boolean releaseSharedState(int releases) { - throw new UnsupportedOperationException(); - } - public void checkConditionAccess(Thread thread, boolean waiting) { - if (state().get() == 0) throw new IllegalMonitorStateException(); + if (get() == 0) throw new IllegalMonitorStateException(); } Condition newCondition() { return new ConditionObject(); } private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject(); - state().set(0); // reset to unlocked state + set(0); // reset to unlocked state } } private final Sync sync = new Sync(); public boolean tryLock() { - return sync.acquireExclusiveState(false, 1, null) >= 0; + return sync.acquireExclusiveState(false, 1) >= 0; } public void lock() { - if (!tryLock()) sync.acquireExclusiveUninterruptibly(1); + sync.acquireExclusiveUninterruptibly(1); } public void lockInterruptibly() throws InterruptedException { sync.acquireExclusiveInterruptibly(1); @@ -75,7 +67,7 @@ public class AbstractQueuedSynchronizerT } public void unlock() { sync.releaseExclusive(1); } public Condition newCondition() { return sync.newCondition(); } - public boolean isLocked() { return sync.state().get() != 0; } + public boolean isLocked() { return sync.get() != 0; } public boolean hasQueuedThreads() { return sync.hasQueuedThreads(); } } @@ -119,7 +111,7 @@ public class AbstractQueuedSynchronizerT } /** - * trylock on an unlocked lock succeeds + * tryLock on an unlocked lock succeeds */ public void testTryLock() { Mutex rl = new Mutex(); @@ -158,7 +150,7 @@ public class AbstractQueuedSynchronizerT } /** - * timed trylock is interruptible. + * timed tryLock is interruptible. */ public void testInterruptedException2() { final Mutex lock = new Mutex(); @@ -181,7 +173,7 @@ public class AbstractQueuedSynchronizerT /** - * Trylock on a locked lock fails + * TryLock on a locked lock fails */ public void testTryLockWhenLocked() { final Mutex lock = new Mutex(); @@ -201,7 +193,7 @@ public class AbstractQueuedSynchronizerT } /** - * Timed trylock on a locked lock times out + * Timed tryLock on a locked lock times out */ public void testTryLock_Timeout() { final Mutex lock = new Mutex();