38 |
|
* The {@link Executors} class provides convenient factory methods for |
39 |
|
* the ScheduledExecutorService implementations provided in this package. |
40 |
|
* |
41 |
+ |
* <h3>Usage Example</h3> |
42 |
+ |
* |
43 |
+ |
* Here is a class with a method that sets up a ScheduledExecutorService |
44 |
+ |
* to beep every ten seconds for an hour: |
45 |
+ |
* |
46 |
+ |
* <pre> |
47 |
+ |
* import static java.util.concurrent.TimeUnit; |
48 |
+ |
* class BeeperControl { |
49 |
+ |
* private final ScheduledExecutorService scheduler = |
50 |
+ |
* Executors.newSingleThreadScheduledExecutor(); |
51 |
+ |
* |
52 |
+ |
* public void beepForAnHour() { |
53 |
+ |
* final Runnable beeper = new Runnable() { |
54 |
+ |
* public void run() { System.out.println("beep"); } |
55 |
+ |
* }; |
56 |
+ |
* final ScheduledFuture<?> beeperHandle = |
57 |
+ |
* scheduler.scheduleAtFixedRate(beeper, 10, 10, SECONDS); |
58 |
+ |
* scheduler.schedule(new Runnable() { |
59 |
+ |
* public void run() { beeperHandle.cancel(true); } |
60 |
+ |
* }, 60 * 60, SECONDS); |
61 |
+ |
* } |
62 |
+ |
* } |
63 |
+ |
* </pre> |
64 |
+ |
* |
65 |
|
* @since 1.5 |
66 |
|
* @author Doug Lea |
67 |
|
*/ |