| java.lang.Object java.util.Timer
Timer | public class Timer (Code) | | Timers are used to schedule jobs for execution in a background process. A
single thread is used for the scheduling and this thread has the option of
being a daemon thread. By calling cancel you can terminate a
timer and it's associated thread. All tasks which are scheduled to run after
this point are cancelled. Tasks are executed sequentially but are subject to
the delays from other tasks run methods. If a specific task takes an
excessive amount of time to run it may impact the time at which subsequent
tasks may run.
The Timer task does not offer any guarantees about the real-time nature of
scheduling tasks as it's underlying implementation relies on the
Object.wait(long) method.
Multiple threads can share a single Timer without the need for their own
synchronization.
See Also: TimerTask See Also: java.lang.Object.wait(long) |
Constructor Summary | |
public | Timer(boolean isDaemon) Creates a new Timer which may be specified to be run as a Daemon Thread. | public | Timer() Creates a new non-daemon Timer. | public | Timer(String name, boolean isDaemon) | public | Timer(String name) |
Method Summary | |
public void | cancel() Cancels the Timer and removed any scheduled tasks. | public int | purge() | public void | schedule(TimerTask task, Date when) Schedule a task for single execution. | public void | schedule(TimerTask task, long delay) Schedule a task for single execution after a specific delay. | public void | schedule(TimerTask task, long delay, long period) Schedule a task for repeated fix-delay execution after a specific delay. | public void | schedule(TimerTask task, Date when, long period) Schedule a task for repeated fix-delay execution after a specific time
has been reached. | public void | scheduleAtFixedRate(TimerTask task, long delay, long period) Schedule a task for repeated fixed-rate execution after a specific delay
has been happened. | public void | scheduleAtFixedRate(TimerTask task, Date when, long period) Schedule a task for repeated fixed-rate execution after a specific time
has been reached. |
Timer | public Timer(boolean isDaemon)(Code) | | Creates a new Timer which may be specified to be run as a Daemon Thread.
Parameters: isDaemon - true if Timers thread should be a daemon thread. |
Timer | public Timer()(Code) | | Creates a new non-daemon Timer.
|
cancel | public void cancel()(Code) | | Cancels the Timer and removed any scheduled tasks. If there is a
currently running task it is not effected. No more tasks may be scheduled
on this Timer. Subsequent calls do nothing.
|
schedule | public void schedule(TimerTask task, Date when)(Code) | | Schedule a task for single execution. If when is less than the current
time, it will be scheduled to executed as soon as possible.
Parameters: task - The task to schedule Parameters: when - Time of execution exception: IllegalArgumentException - if when.getTime() < 0 exception: IllegalStateException - if the timer has been cancelled, the task has beenscheduled or cancelled. |
schedule | public void schedule(TimerTask task, long delay)(Code) | | Schedule a task for single execution after a specific delay.
Parameters: task - The task to schedule Parameters: delay - Amount of time before execution exception: IllegalArgumentException - if delay < 0 exception: IllegalStateException - if the timer has been cancelled, the task has beenscheduled or cancelled. |
schedule | public void schedule(TimerTask task, long delay, long period)(Code) | | Schedule a task for repeated fix-delay execution after a specific delay.
Parameters: task - The task to schedule Parameters: delay - Amount of time before first execution Parameters: period - Amount of time between subsequent executions exception: IllegalArgumentException - if delay < 0 or period < 0 exception: IllegalStateException - if the timer has been cancelled, the task has beenscheduled or cancelled. |
schedule | public void schedule(TimerTask task, Date when, long period)(Code) | | Schedule a task for repeated fix-delay execution after a specific time
has been reached.
Parameters: task - The task to schedule Parameters: when - Time of first execution Parameters: period - Amount of time between subsequent executions exception: IllegalArgumentException - if when.getTime() < 0 or period < 0 exception: IllegalStateException - if the timer has been cancelled, the task has beenscheduled or cancelled. |
scheduleAtFixedRate | public void scheduleAtFixedRate(TimerTask task, long delay, long period)(Code) | | Schedule a task for repeated fixed-rate execution after a specific delay
has been happened. The difference of fixed-rate is that it may bunch up
subsequent task runs to try to get the task repeating at it's desired
time.
Parameters: task - The task to schedule Parameters: delay - Amount of time before first execution Parameters: period - Amount of time between subsequent executions exception: IllegalArgumentException - if delay < 0 or period < 0 exception: IllegalStateException - if the timer has been cancelled, the task has beenscheduled or cancelled. |
scheduleAtFixedRate | public void scheduleAtFixedRate(TimerTask task, Date when, long period)(Code) | | Schedule a task for repeated fixed-rate execution after a specific time
has been reached. The difference of fixed-rate is that it may bunch up
subsequent task runs to try to get the task repeating at it's desired
time.
Parameters: task - The task to schedule Parameters: when - Time of first execution Parameters: period - Amount of time between subsequent executions exception: IllegalArgumentException - if when.getTime() < 0 or period < 0 exception: IllegalStateException - if the timer has been cancelled, the task has beenscheduled or cancelled. |
|
|