34 |
|
public boolean isHeldExclusively() { return getState() == 1; } |
35 |
|
|
36 |
|
public boolean tryAcquire(int acquires) { |
37 |
< |
assertTrue(acquires == 1); |
37 |
> |
assertEquals(1, acquires); |
38 |
|
return compareAndSetState(0, 1); |
39 |
|
} |
40 |
|
|
44 |
|
return true; |
45 |
|
} |
46 |
|
|
47 |
< |
public AbstractQueuedSynchronizer.ConditionObject newCondition() { return new AbstractQueuedSynchronizer.ConditionObject(); } |
47 |
> |
public AbstractQueuedSynchronizer.ConditionObject newCondition() { |
48 |
> |
return new AbstractQueuedSynchronizer.ConditionObject(); |
49 |
> |
} |
50 |
|
|
51 |
|
} |
52 |
|
|
347 |
|
sync.acquire(1); |
348 |
|
Thread t = new Thread(new CheckedRunnable() { |
349 |
|
public void realRun() { |
350 |
< |
threadAssertFalse(sync.tryAcquire(1)); |
350 |
> |
assertFalse(sync.tryAcquire(1)); |
351 |
|
}}); |
352 |
|
|
353 |
|
t.start(); |
644 |
|
Thread t = new Thread(new CheckedRunnable() { |
645 |
|
public void realRun() throws InterruptedException { |
646 |
|
sync.acquire(1); |
647 |
< |
threadAssertFalse(sync.hasWaiters(c)); |
648 |
< |
threadAssertEquals(0, sync.getWaitQueueLength(c)); |
647 |
> |
assertFalse(sync.hasWaiters(c)); |
648 |
> |
assertEquals(0, sync.getWaitQueueLength(c)); |
649 |
|
c.await(); |
650 |
|
sync.release(1); |
651 |
|
}}); |
675 |
|
Thread t1 = new Thread(new CheckedRunnable() { |
676 |
|
public void realRun() throws InterruptedException { |
677 |
|
sync.acquire(1); |
678 |
< |
threadAssertFalse(sync.hasWaiters(c)); |
679 |
< |
threadAssertEquals(0, sync.getWaitQueueLength(c)); |
678 |
> |
assertFalse(sync.hasWaiters(c)); |
679 |
> |
assertEquals(0, sync.getWaitQueueLength(c)); |
680 |
|
c.await(); |
681 |
|
sync.release(1); |
682 |
|
}}); |
684 |
|
Thread t2 = new Thread(new CheckedRunnable() { |
685 |
|
public void realRun() throws InterruptedException { |
686 |
|
sync.acquire(1); |
687 |
< |
threadAssertTrue(sync.hasWaiters(c)); |
688 |
< |
threadAssertEquals(1, sync.getWaitQueueLength(c)); |
687 |
> |
assertTrue(sync.hasWaiters(c)); |
688 |
> |
assertEquals(1, sync.getWaitQueueLength(c)); |
689 |
|
c.await(); |
690 |
|
sync.release(1); |
691 |
|
}}); |
719 |
|
Thread t1 = new Thread(new CheckedRunnable() { |
720 |
|
public void realRun() throws InterruptedException { |
721 |
|
sync.acquire(1); |
722 |
< |
threadAssertTrue(sync.getWaitingThreads(c).isEmpty()); |
722 |
> |
assertTrue(sync.getWaitingThreads(c).isEmpty()); |
723 |
|
c.await(); |
724 |
|
sync.release(1); |
725 |
|
}}); |
727 |
|
Thread t2 = new Thread(new CheckedRunnable() { |
728 |
|
public void realRun() throws InterruptedException { |
729 |
|
sync.acquire(1); |
730 |
< |
threadAssertFalse(sync.getWaitingThreads(c).isEmpty()); |
730 |
> |
assertFalse(sync.getWaitingThreads(c).isEmpty()); |
731 |
|
c.await(); |
732 |
|
sync.release(1); |
733 |
|
}}); |
934 |
|
|
935 |
|
Thread t = new Thread(new CheckedRunnable() { |
936 |
|
public void realRun() throws InterruptedException { |
937 |
< |
threadAssertFalse(l.isSignalled()); |
937 |
> |
assertFalse(l.isSignalled()); |
938 |
|
l.acquireSharedInterruptibly(0); |
939 |
< |
threadAssertTrue(l.isSignalled()); |
939 |
> |
assertTrue(l.isSignalled()); |
940 |
|
}}); |
941 |
|
|
942 |
|
t.start(); |
977 |
|
final BooleanLatch l = new BooleanLatch(); |
978 |
|
Thread t = new Thread(new CheckedInterruptedRunnable() { |
979 |
|
public void realRun() throws InterruptedException { |
980 |
< |
threadAssertFalse(l.isSignalled()); |
980 |
> |
assertFalse(l.isSignalled()); |
981 |
|
l.acquireSharedInterruptibly(0); |
982 |
|
}}); |
983 |
|
|