1 |
|
/* |
2 |
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
< |
* http://creativecommons.org/licenses/publicdomain |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
import java.util.concurrent.locks.*; |
7 |
|
|
50 |
|
t2.join(MEDIUM_DELAY_MS); |
51 |
|
assertTrue(!t1.isAlive()); |
52 |
|
assertTrue(!t2.isAlive()); |
53 |
– |
|
53 |
|
} |
54 |
|
|
55 |
|
/** |
67 |
|
* Read lock succeeds if write locked by current thread even if |
68 |
|
* other threads are waiting |
69 |
|
*/ |
70 |
< |
public void testReadHoldingWriteLock2() throws Exception{ |
70 |
> |
public void testReadHoldingWriteLock2() throws Exception { |
71 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
72 |
|
lock.writeLock().lock(); |
73 |
|
Thread t1 = new Thread(new Runnable() { |
100 |
|
/** |
101 |
|
* Fair Read trylock succeeds if write locked by current thread |
102 |
|
*/ |
103 |
< |
public void testReadHoldingWriteLockFair() throws Exception{ |
103 |
> |
public void testReadHoldingWriteLockFair() throws Exception { |
104 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true); |
105 |
|
lock.writeLock().lock(); |
106 |
|
assertTrue(lock.readLock().tryLock()); |
140 |
|
t2.join(MEDIUM_DELAY_MS); |
141 |
|
assertTrue(!t1.isAlive()); |
142 |
|
assertTrue(!t2.isAlive()); |
144 |
– |
|
145 |
– |
|
143 |
|
} |
144 |
|
} |