Java Reference
In-Depth Information
Schedules the given
task
to execute on a fixed-delay schedule
until cancelled, starting after the given
delay
, executing every
period
milliseconds.
public void
scheduleAtFixedRate(TimerTask task, Date firstTime, long
period)
Schedules the given
task
to execute on a fixed-rate schedule
until cancelled, starting at
firstTime
, executing every
period
milliseconds.
public void
scheduleAtFixedRate(TimerTask task, long delay, long
period)
Schedules the given
task
to execute on a fixed-rate schedule
until cancelled, starting after the given
delay
, executing every
period
milliseconds.
Any time you specify that is in the past schedules an immediate exe-
cution. All times are in millisecondsthe
Date
class's
getTime
method con-
schedule future executions, and
wait
, like
sleep
, does not guarantee pre-
cision. If a delay is so large that adding it to the current time would
cause an overflow, you will get an
IllegalArgumentException
.
A
TimerTask
object can only be scheduled with one
Timer
, and a cancelled
Timer
cannot have any new tasks scheduled. If you attempt to schedule
a task that violates either of these restrictions or if you schedule an
already cancelled
TimerTask
, you will get an
IllegalStateException
.
A
Timer
's thread is subject to the usual thread scheduling of a system
and takes no steps to influence its priority in any wayit is created with
the priority of the thread that created the
Timer
. If you need to boost
the priority of a given task when it is executing, set the thread prior-
ity within the
run
method. If you want to boost the priority of the
Timer