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 |
5 |
< |
* Other contributors include Andrew Wright, Jeffrey Hayes, |
6 |
< |
* Pat Fisher, Mike Judd. |
5 |
> |
* Other contributors include Andrew Wright, Jeffrey Hayes, |
6 |
> |
* Pat Fisher, Mike Judd. |
7 |
|
*/ |
8 |
|
|
9 |
|
import junit.framework.*; |
13 |
|
|
14 |
|
public class LockSupportTest extends JSR166TestCase{ |
15 |
|
public static void main(String[] args) { |
16 |
< |
junit.textui.TestRunner.run (suite()); |
16 |
> |
junit.textui.TestRunner.run (suite()); |
17 |
|
} |
18 |
|
public static Test suite() { |
19 |
|
return new TestSuite(LockSupportTest.class); |
22 |
|
/** |
23 |
|
* park is released by unpark occurring after park |
24 |
|
*/ |
25 |
< |
public void testPark() { |
25 |
> |
public void testPark() { |
26 |
|
Thread t = new Thread(new Runnable() { |
27 |
|
public void run() { |
28 |
|
try { |
46 |
|
/** |
47 |
|
* park is released by unpark occurring before park |
48 |
|
*/ |
49 |
< |
public void testPark2() { |
49 |
> |
public void testPark2() { |
50 |
|
Thread t = new Thread(new Runnable() { |
51 |
|
public void run() { |
52 |
|
try { |
68 |
|
} |
69 |
|
|
70 |
|
/** |
71 |
< |
* park is released by interrupt |
71 |
> |
* park is released by interrupt |
72 |
|
*/ |
73 |
< |
public void testPark3() { |
73 |
> |
public void testPark3() { |
74 |
|
Thread t = new Thread(new Runnable() { |
75 |
|
public void run() { |
76 |
|
try { |
94 |
|
/** |
95 |
|
* park returns if interrupted before park |
96 |
|
*/ |
97 |
< |
public void testPark4() { |
97 |
> |
public void testPark4() { |
98 |
|
final ReentrantLock lock = new ReentrantLock(); |
99 |
|
lock.lock(); |
100 |
|
Thread t = new Thread(new Runnable() { |
121 |
|
/** |
122 |
|
* parkNanos times out if not unparked |
123 |
|
*/ |
124 |
< |
public void testParkNanos() { |
124 |
> |
public void testParkNanos() { |
125 |
|
Thread t = new Thread(new Runnable() { |
126 |
|
public void run() { |
127 |
|
try { |
144 |
|
/** |
145 |
|
* parkUntil times out if not unparked |
146 |
|
*/ |
147 |
< |
public void testParkUntil() { |
147 |
> |
public void testParkUntil() { |
148 |
|
Thread t = new Thread(new Runnable() { |
149 |
|
public void run() { |
150 |
|
try { |