|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Timer
public class Timer
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.
TimerTask,
Object.wait(long)| Constructor Summary | |
|---|---|
Timer()
Creates a new non-daemon Timer. |
|
Timer(boolean isDaemon)
Creates a new Timer which may be specified to be run as a Daemon Thread. |
|
Timer(String name)
|
|
Timer(String name,
boolean isDaemon)
|
|
| Method Summary | |
|---|---|
void |
cancel()
Cancels the Timer and removed any scheduled tasks. |
int |
purge()
|
void |
schedule(TimerTask task,
Date when)
Schedule a task for single execution. |
void |
schedule(TimerTask task,
Date when,
long period)
Schedule a task for repeated fix-delay execution after a specific time has been reached. |
void |
schedule(TimerTask task,
long delay)
Schedule a task for single execution after a specific delay. |
void |
schedule(TimerTask task,
long delay,
long period)
Schedule a task for repeated fix-delay execution after a specific delay. |
void |
scheduleAtFixedRate(TimerTask task,
Date when,
long period)
Schedule a task for repeated fixed-rate execution after a specific time has been reached. |
void |
scheduleAtFixedRate(TimerTask task,
long delay,
long period)
Schedule a task for repeated fixed-rate execution after a specific delay has been happened. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Timer(boolean isDaemon)
isDaemon - true if Timers thread should be a daemon thread.public Timer()
public Timer(String name,
boolean isDaemon)
public Timer(String name)
| Method Detail |
|---|
public void cancel()
public int purge()
public void schedule(TimerTask task,
Date when)
task - The task to schedulewhen - Time of execution
IllegalArgumentException - if when.getTime() < 0
IllegalStateException - if the timer has been cancelled, the task has been
scheduled or cancelled.
public void schedule(TimerTask task,
long delay)
task - The task to scheduledelay - Amount of time before execution
IllegalArgumentException - if delay < 0
IllegalStateException - if the timer has been cancelled, the task has been
scheduled or cancelled.
public void schedule(TimerTask task,
long delay,
long period)
task - The task to scheduledelay - Amount of time before first executionperiod - Amount of time between subsequent executions
IllegalArgumentException - if delay < 0 or period < 0
IllegalStateException - if the timer has been cancelled, the task has been
scheduled or cancelled.
public void schedule(TimerTask task,
Date when,
long period)
task - The task to schedulewhen - Time of first executionperiod - Amount of time between subsequent executions
IllegalArgumentException - if when.getTime() < 0 or period < 0
IllegalStateException - if the timer has been cancelled, the task has been
scheduled or cancelled.
public void scheduleAtFixedRate(TimerTask task,
long delay,
long period)
task - The task to scheduledelay - Amount of time before first executionperiod - Amount of time between subsequent executions
IllegalArgumentException - if delay < 0 or period < 0
IllegalStateException - if the timer has been cancelled, the task has been
scheduled or cancelled.
public void scheduleAtFixedRate(TimerTask task,
Date when,
long period)
task - The task to schedulewhen - Time of first executionperiod - Amount of time between subsequent executions
IllegalArgumentException - if when.getTime() < 0 or period < 0
IllegalStateException - if the timer has been cancelled, the task has been
scheduled or cancelled.
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||