ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/ScheduledExecutorService.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/ScheduledExecutorService.java (file contents):
Revision 1.7 by dl, Fri Jan 9 17:15:48 2004 UTC vs.
Revision 1.8 by dl, Fri Jan 9 18:40:03 2004 UTC

# Line 38 | Line 38 | import java.util.*;
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   */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines