57 |
|
return super.getQueuedThreads(); |
58 |
|
} |
59 |
|
public PublicCondition newCondition() { |
60 |
< |
return new PublicCondition(this); |
60 |
> |
return new PublicCondition(); |
61 |
|
} |
62 |
|
|
63 |
< |
static class PublicCondition extends AbstractReentrantLock.ConditionObject { |
64 |
< |
PublicCondition(PublicReentrantReadWriteLock l) { super(l); } |
63 |
> |
class PublicCondition extends ReentrantReadWriteLock.WriterConditionObject { |
64 |
> |
PublicCondition() { } |
65 |
|
public Collection<Thread> getWaitingThreads() { |
66 |
|
return super.getWaitingThreads(); |
67 |
|
} |
76 |
|
ReentrantReadWriteLock rl = new ReentrantReadWriteLock(); |
77 |
|
assertFalse(rl.isFair()); |
78 |
|
assertFalse(rl.isWriteLocked()); |
79 |
< |
assertEquals(0, rl.getReadLocks()); |
79 |
> |
assertEquals(0, rl.getReadLockCount()); |
80 |
|
ReentrantReadWriteLock r2 = new ReentrantReadWriteLock(true); |
81 |
|
assertTrue(r2.isFair()); |
82 |
|
assertFalse(r2.isWriteLocked()); |
83 |
< |
assertEquals(0, r2.getReadLocks()); |
83 |
> |
assertEquals(0, r2.getReadLockCount()); |
84 |
|
} |
85 |
|
|
86 |
|
/** |
91 |
|
rl.writeLock().lock(); |
92 |
|
assertTrue(rl.isWriteLocked()); |
93 |
|
assertTrue(rl.isWriteLockedByCurrentThread()); |
94 |
< |
assertEquals(0, rl.getReadLocks()); |
94 |
> |
assertEquals(0, rl.getReadLockCount()); |
95 |
|
rl.writeLock().unlock(); |
96 |
|
assertFalse(rl.isWriteLocked()); |
97 |
|
assertFalse(rl.isWriteLockedByCurrentThread()); |
98 |
< |
assertEquals(0, rl.getReadLocks()); |
98 |
> |
assertEquals(0, rl.getReadLockCount()); |
99 |
|
rl.readLock().lock(); |
100 |
|
assertFalse(rl.isWriteLocked()); |
101 |
|
assertFalse(rl.isWriteLockedByCurrentThread()); |
102 |
< |
assertEquals(1, rl.getReadLocks()); |
102 |
> |
assertEquals(1, rl.getReadLockCount()); |
103 |
|
rl.readLock().unlock(); |
104 |
|
assertFalse(rl.isWriteLocked()); |
105 |
|
assertFalse(rl.isWriteLockedByCurrentThread()); |
106 |
< |
assertEquals(0, rl.getReadLocks()); |
106 |
> |
assertEquals(0, rl.getReadLockCount()); |
107 |
|
} |
108 |
|
|
109 |
|
|
115 |
|
rl.writeLock().lock(); |
116 |
|
assertTrue(rl.isWriteLocked()); |
117 |
|
assertTrue(rl.isWriteLockedByCurrentThread()); |
118 |
< |
assertEquals(0, rl.getReadLocks()); |
118 |
> |
assertEquals(0, rl.getReadLockCount()); |
119 |
|
rl.writeLock().unlock(); |
120 |
|
assertFalse(rl.isWriteLocked()); |
121 |
|
assertFalse(rl.isWriteLockedByCurrentThread()); |
122 |
< |
assertEquals(0, rl.getReadLocks()); |
122 |
> |
assertEquals(0, rl.getReadLockCount()); |
123 |
|
rl.readLock().lock(); |
124 |
|
assertFalse(rl.isWriteLocked()); |
125 |
|
assertFalse(rl.isWriteLockedByCurrentThread()); |
126 |
< |
assertEquals(1, rl.getReadLocks()); |
126 |
> |
assertEquals(1, rl.getReadLockCount()); |
127 |
|
rl.readLock().unlock(); |
128 |
|
assertFalse(rl.isWriteLocked()); |
129 |
|
assertFalse(rl.isWriteLockedByCurrentThread()); |
130 |
< |
assertEquals(0, rl.getReadLocks()); |
130 |
> |
assertEquals(0, rl.getReadLockCount()); |
131 |
|
} |
132 |
|
|
133 |
|
/** |
920 |
|
*/ |
921 |
|
public void testHasWaiters() { |
922 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
923 |
< |
final AbstractReentrantLock.ConditionObject c = (AbstractReentrantLock.ConditionObject)(lock.writeLock().newCondition()); |
923 |
> |
final ReentrantReadWriteLock.WriterConditionObject c = (ReentrantReadWriteLock.WriterConditionObject)(lock.writeLock().newCondition()); |
924 |
|
Thread t = new Thread(new Runnable() { |
925 |
|
public void run() { |
926 |
|
try { |
962 |
|
*/ |
963 |
|
public void testGetWaitQueueLength() { |
964 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
965 |
< |
final AbstractReentrantLock.ConditionObject c = (AbstractReentrantLock.ConditionObject)(lock.writeLock().newCondition()); |
965 |
> |
final ReentrantReadWriteLock.WriterConditionObject c = (ReentrantReadWriteLock.WriterConditionObject)(lock.writeLock().newCondition()); |
966 |
|
Thread t1 = new Thread(new Runnable() { |
967 |
|
public void run() { |
968 |
|
try { |