Methods Summary |
---|
public void | cancel()Stop the timer thread, and discard all scheduled tasks
synchronized(tasks) { // Only one thread at a time!
timer.pleaseStop(); // Set a flag asking the thread to stop
tasks.clear(); // Discard all tasks
tasks.notify(); // Wake up the thread if it is in wait().
}
|
void | schedule(TimerTask task)
synchronized(tasks) { // Only one thread can modify tasks at a time!
tasks.add(task); // Add the task to the sorted set of tasks
tasks.notify(); // Wake up the thread if it is waiting
}
|
public void | schedule(TimerTask task, long delay)Schedule a single execution after delay milliseconds
task.schedule(System.currentTimeMillis() + delay, 0, false);
schedule(task);
|
public void | schedule(TimerTask task, java.util.Date time)Schedule a single execution at the specified time
task.schedule(time.getTime(), 0, false);
schedule(task);
|
public void | schedule(TimerTask task, java.util.Date firstTime, long period)Schedule a periodic execution starting at the specified time
task.schedule(firstTime.getTime(), period, false);
schedule(task);
|
public void | schedule(TimerTask task, long delay, long period)Schedule a periodic execution starting after the specified delay
task.schedule(System.currentTimeMillis() + delay, period, false);
schedule(task);
|
public void | scheduleAtFixedRate(TimerTask task, long delay, long period)Schedule a periodic execution starting after the specified delay.
Schedule fixed-rate executions period ms after the start of the last.
Instead of fixed-interval executions measured from the end of the last.
task.schedule(System.currentTimeMillis() + delay, period, true);
schedule(task);
|
public void | scheduleAtFixedRate(TimerTask task, java.util.Date firstTime, long period)Schedule a periodic execution starting after the specified time
task.schedule(firstTime.getTime(), period, true);
schedule(task);
|