Created
April 1, 2016 06:11
-
-
Save jqno/cee0a7a30d9c2e7b0c89c74c814fee26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void waitAMinute() { | |
reallyReallyWait(60000); | |
} | |
public void reallyReallyWait(int millis) { | |
int before = System.currentTimeMillis(); | |
try { | |
Thread.sleep(millis); | |
} | |
catch (InterruptedException | StackOverflowError e) { | |
int after = System.currentTimeMillis(); | |
int elapsed = after - before; | |
// Make sure we really, REALLY wait the full allotted time. | |
reallyReallyWait(millis - elapsed); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment