Q:

How to implement a frontend view of a backend countup timer in java?

Trying to implement a timer for my game that I'm making. I have a backend class Game that has an int timeElapsed() method. This gives me elapsed time since the start in milliseconds. I also have a front end view that needs an update of this elapsed time. What is the best way to synchronize these two values? I could set up a daemon to call game.timeElapsed() every second, but it seems that there must be a better way to do this.
Another idea I had was to put some timekeeping in the frontend, but this seems like a violation of separation of responsibilities.
The Stopwatch class that I'm using to keep track of time does not support callbacks.
Thoughts?

A:

Use the java.util.Timer class, to periodically update the view. Call game.timeElapsed() in each iteration, don't keep two Stopwatch-objects around.

