The second parameter of schedule
refers to the first execution, therefore it should be the informed period plus the sum of the second desired, as referenced below:
http://docs.oracle.com/javase/7/docs/api/java/util/Timer.html
public void schedule(TimerTask task,
Date firstTime,
long period)
Schedules the specified task for repeated Fixed-delay Execution, Beginning at the specified time. Subsequent
executions take place at approximately regular intervals, separated by
the specified period.
In Fixed-delay Execution, each Execution is
scheduled relative to the current Execution time of the Previous
Execution. If an Execution is delayed for any Reason (such as Garbage
Collection or other background Activity), subsequent executions will
be delayed as well. In the long run, the Frequency of Execution will
generally be Slightly Lower than the reciprocal of the specified
period (assuming the system clock underlying Object.Wait(long) is
Accurate). As a consequence of the above, if the scheduled first time
is in the Past, it is scheduled for immediate Execution.
Fixed-delay Execution is appropriate for recurring activities that
require "smoothness." In other words, it is appropriate for activities
Where it is more Important to Keep the Frequency Accurate in the short
run than in the long run. This includes Most Animation tasks, such as
blinking a cursor at regular intervals. It also includes tasks wherein
regular Activity is performed in Response to Human input, such as
Automatically Repeating to Character as long as a key is Held down.
Parameters:
task - task to be scheduled.
firsttime - First time at which task is to be executed.
period - time in milliseconds between successive task executions.
Throws: Illegalargumentexception - if firsttime.getTime() < 0, or period <= 0
Illegalstateexception - if task was already scheduled or cancelled, timer was cancelled, or timer thread terminated.
Nullpointerexception - if task or firsttime is null
Dear Eduardo, did my statement solve your problem? If yes, would you kindly mark the question as answered, to assist in the organization?
– Tiago César Oliveira