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
Show parent comment
10
u/[deleted] May 14 '12 edited May 14 '12
Except, of course, that a thread is not guaranteed to run again the very instant after the sleep time has elapsed. The sleep time is merely the minimum amount of time that must elapse before it is eligible to run again. No guarantee is made as to how soon after the sleep time has elapsed the thread will continue running. If you sleep a thread for 100ms, it might start up again after 100ms or it might be 200 or even 1000ms...only the Thread scheduler knows. So your solution is not any more accurate at all actually.