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 |
|
* Other contributors include Andrew Wright, Jeffrey Hayes, |
6 |
|
* Pat Fisher, Mike Judd. |
7 |
|
*/ |
14 |
|
public class ExchangerTest extends JSR166TestCase { |
15 |
|
|
16 |
|
public static void main(String[] args) { |
17 |
< |
junit.textui.TestRunner.run (suite()); |
17 |
> |
junit.textui.TestRunner.run(suite()); |
18 |
|
} |
19 |
|
public static Test suite() { |
20 |
|
return new TestSuite(ExchangerTest.class); |
75 |
|
}}); |
76 |
|
|
77 |
|
t.start(); |
78 |
< |
Thread.sleep(SHORT_DELAY_MS); |
78 |
> |
delay(SHORT_DELAY_MS); |
79 |
|
t.interrupt(); |
80 |
|
t.join(); |
81 |
|
} |
91 |
|
}}); |
92 |
|
|
93 |
|
t.start(); |
94 |
< |
Thread.sleep(SHORT_DELAY_MS); |
94 |
> |
delay(SHORT_DELAY_MS); |
95 |
|
t.interrupt(); |
96 |
|
t.join(); |
97 |
|
} |
123 |
|
Thread t2 = new Thread(new CheckedRunnable() { |
124 |
|
public void realRun() throws InterruptedException { |
125 |
|
assertSame(one, e.exchange(two)); |
126 |
< |
Thread.sleep(SMALL_DELAY_MS); |
126 |
> |
delay(SMALL_DELAY_MS); |
127 |
|
assertSame(three, e.exchange(one)); |
128 |
|
}}); |
129 |
|
Thread t3 = new Thread(new CheckedRunnable() { |
130 |
|
public void realRun() throws InterruptedException { |
131 |
< |
Thread.sleep(SMALL_DELAY_MS); |
131 |
> |
delay(SMALL_DELAY_MS); |
132 |
|
assertSame(one, e.exchange(three)); |
133 |
|
}}); |
134 |
|
|
135 |
|
t1.start(); |
136 |
|
t2.start(); |
137 |
|
t3.start(); |
138 |
< |
Thread.sleep(SHORT_DELAY_MS); |
138 |
> |
delay(SHORT_DELAY_MS); |
139 |
|
t1.interrupt(); |
140 |
|
t1.join(); |
141 |
|
t2.join(); |