Currently I am using a timer to execute some function every interval time. However, later on when I want to change the interval of executing the function, I cannot cancel the previous schedule. how this can be solved? Thanks
With the timer.cancel()
method you can cancels the Timer and all scheduled tasks. (see API documentation) or you can call the cancel method on your TimerTask timertask.cancel()
(see API documentation)
If you want to change the scheduled time you should cancel the TimerTask and add a new TimerTask.