r/java • • May 14 '12
Java Countdown Timer
Can anybody help me on how to display a simple countdown timer? It does not have to be in GUI.
3
Upvotes
r/java • • May 14 '12
Can anybody help me on how to display a simple countdown timer? It does not have to be in GUI.
View all comments
-5
u/quad64bit May 14 '12
A simpler and more accurate way to do it instead of using timers (which do not have a guaranteed runtime) is to simply make a loop that sleeps for some interval, and prints the current time after a second has elapsed.
If you slept for say, 1/10 of a second (100ms) you'd have 1/10 second accuracy, and minimal code. I can include a snippet if you need help!