How can I change period of Timer at runtime?
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
// read new period
period = getPeriod();
doSomething();
}
}, 0, period);
You cannot do this directly, but you can cancel the tasks on the Timer
and reschedule them with the desired period.
There is no getPeriod
method.