/[classpath]/classpath/java/util/TimerTask.java
ViewVC logotype

Diff of /classpath/java/util/TimerTask.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by mark, Tue Jan 22 22:27:01 2002 UTC revision 1.5 by mark, Sun May 26 10:59:30 2002 UTC
# Line 44  package java.util; Line 44  package java.util;
44   * it should have been scheduled and cancel itself when no longer needed.   * it should have been scheduled and cancel itself when no longer needed.
45   * <p>   * <p>
46   * Example:   * Example:
47   * <code>   * <pre>
48   *  Timer timer = new Timer();   *  Timer timer = new Timer();
49   *  TimerTask task = new TimerTask() {   *  TimerTask task = new TimerTask() {
50   *      public void run() {   *      public void run() {
51   *      if (this.scheduledExecutionTime() < System.currentTimeMillis() + 500)   *      if (this.scheduledExecutionTime() &lt; System.currentTimeMillis() + 500)
52   *          // Do something   *          // Do something
53   *      else   *      else
54   *          // Complain: We are more then half a second late!   *          // Complain: We are more then half a second late!
# Line 56  package java.util; Line 56  package java.util;
56   *          this.cancel(); // This was our last execution   *          this.cancel(); // This was our last execution
57   *  };   *  };
58   *  timer.scheduleAtFixedRate(task, 1000, 1000); // schedule every second   *  timer.scheduleAtFixedRate(task, 1000, 1000); // schedule every second
59   * </code>   * </pre>
60   * <p>   * <p>
61   * Note that a TimerTask object is a one shot object and can only given once   * Note that a TimerTask object is a one shot object and can only given once
62   * to a Timer. (The Timer will use the TimerTask object for bookkeeping,   * to a Timer. (The Timer will use the TimerTask object for bookkeeping,

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26