You are using the version of Timer.schedule()
that only runs a task once: Timer.schedule(TimerTask, long)
, after the specified delay.
You need to specify one of the versions that actually repeats the task: either Timer.schedule(TimerTask, long, long)
or Timer.scheduleAtFixedRate(TimerTask, long, long)
. In both of these, the third argument determines how much time will pass between each execution. The difference is that scheduleAtFixedRate
will try to keep the beginning of each task invocation at a nearly constant period from the start time, while schedule
will maintain a fairly constant gap between the end of one execution and the beginning of the other.