6 |
|
* Pat Fisher, Mike Judd. |
7 |
|
*/ |
8 |
|
|
9 |
– |
import junit.framework.*; |
10 |
– |
import java.util.*; |
11 |
– |
import java.util.concurrent.*; |
9 |
|
import static java.util.concurrent.TimeUnit.MILLISECONDS; |
10 |
+ |
|
11 |
+ |
import java.util.ArrayList; |
12 |
+ |
import java.util.List; |
13 |
+ |
import java.util.concurrent.BlockingQueue; |
14 |
+ |
import java.util.concurrent.Callable; |
15 |
+ |
import java.util.concurrent.CountDownLatch; |
16 |
+ |
import java.util.concurrent.ExecutionException; |
17 |
+ |
import java.util.concurrent.Executors; |
18 |
+ |
import java.util.concurrent.ExecutorService; |
19 |
+ |
import java.util.concurrent.Future; |
20 |
+ |
import java.util.concurrent.RejectedExecutionException; |
21 |
+ |
import java.util.concurrent.ScheduledFuture; |
22 |
+ |
import java.util.concurrent.ScheduledThreadPoolExecutor; |
23 |
+ |
import java.util.concurrent.ThreadFactory; |
24 |
+ |
import java.util.concurrent.ThreadPoolExecutor; |
25 |
|
import java.util.concurrent.atomic.AtomicInteger; |
26 |
|
|
27 |
+ |
import junit.framework.Test; |
28 |
+ |
import junit.framework.TestSuite; |
29 |
+ |
|
30 |
|
public class ScheduledExecutorTest extends JSR166TestCase { |
31 |
|
public static void main(String[] args) { |
32 |
< |
junit.textui.TestRunner.run(suite()); |
32 |
> |
main(suite(), args); |
33 |
|
} |
34 |
|
public static Test suite() { |
35 |
|
return new TestSuite(ScheduledExecutorTest.class); |
161 |
|
long startTime = System.nanoTime(); |
162 |
|
int cycles = 10; |
163 |
|
final CountDownLatch done = new CountDownLatch(cycles); |
164 |
< |
CheckedRunnable task = new CheckedRunnable() { |
164 |
> |
Runnable task = new CheckedRunnable() { |
165 |
|
public void realRun() { done.countDown(); }}; |
166 |
|
ScheduledFuture h = |
167 |
|
p.scheduleAtFixedRate(task, 0, delay, MILLISECONDS); |
189 |
|
long startTime = System.nanoTime(); |
190 |
|
int cycles = 10; |
191 |
|
final CountDownLatch done = new CountDownLatch(cycles); |
192 |
< |
CheckedRunnable task = new CheckedRunnable() { |
192 |
> |
Runnable task = new CheckedRunnable() { |
193 |
|
public void realRun() { done.countDown(); }}; |
194 |
|
ScheduledFuture h = |
195 |
|
p.scheduleWithFixedDelay(task, 0, delay, MILLISECONDS); |