Skip to content

Instantly share code, notes, and snippets.

@jqno
Created April 1, 2016 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jqno/cee0a7a30d9c2e7b0c89c74c814fee26 to your computer and use it in GitHub Desktop.
Save jqno/cee0a7a30d9c2e7b0c89c74c814fee26 to your computer and use it in GitHub Desktop.
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