It seems that the clock widget is what is broken. The user interface widget should display the current state of the model, where the model in this case is the system time. Of course, for the clock, you need to schedule repaint() every second, but when repainting occurs, it should display the system time, and not try to track the time.
This principle applies even to components other than the UI. Determine the tolerance of the component for synchronization errors and get a background thread that updates the component at this interval. During the upgrade, however, the system time is used rather than the independent internal clock.
Update:
The main ScheduledExecutorService does not suffer from this problem, at least on my platform.
ScheduledExecutorService worker = Executors.newScheduledThreadPool(1); worker.schedule(new Runnable() { public void run() { update(); } }, 100, TimeUnit.MILLISECONDS);
erickson
source share