Conventionally, I delay my programs for a short time with Thread.sleep(int)
surrounded with an e.printStackTrace()
try/catch block. I want to do away with the exception handling. I wrote this function:
private static void pause(int millis) {
long end = System.currentTimeMillis() + millis;
while(System.currentTimeMillis() <= end) {
// Do nothing
}
}
But using it uses 15% CPU (an audible affair). How does Thread.sleep(int)
pause without unacceptable CPU usage? My uneducated guess is that it performs some activity which is time consuming, not requiring of much CPU effort, and rather pointless other than for passing time.