This content has been marked as final. Show 1 reply
One reason, among many, is that TimerTask uses the System.currentTimeMillis() method to define all of it's execution scheduling.
The call to System.currentTimeMillis() is providing the host computers representation of 'Wall Time' and does not behave very well when the system clock is adjusted such as when NTP or similar makes adjustments to the clock.
This is especially a problem with large periods between scheduled executions and the system clock is adjusted in large steps.
Or even with short periods, as long as the clock adjustments are large compared to the execution period.
This issue is just one of the many that cause issues with this facility.
There are better solutions, coded to deal with the multitudinous issues of scheduled tasks in the real world; you are better off using the 'concurrency' package rather than the Timer and TimerTask from the util package.