List of utility methods to do Sleep
void | sleep(long ms) sleep Object sleep = new Object(); try { synchronized (sleep) { sleep.wait(ms); } catch (Exception e) { e.printStackTrace(); |
void | sleep(long ms) Sleep for a guaranteed number of milliseconds unless interrupted. long finishAt = System.currentTimeMillis() + ms; long remaining = ms; do { Thread.sleep(remaining); remaining = finishAt - System.currentTimeMillis(); } while (remaining > 0); |
boolean | sleep(long ms) Sleeps the current thread for the specified length of time represented as milliseconds without the need for a try/catch enclosure. if (ms <= 0) { return true; try { Thread.sleep(ms); return true; } catch (InterruptedException e) { e.printStackTrace(); ... |
void | sleep(long msecs, boolean busy_sleep) On most UNIX systems, the minimum sleep time is 10-20ms. if (Thread.interrupted()) throw new InterruptedException(); if (!busy_sleep) { sleep(msecs); return; long start = System.currentTimeMillis(); long stop = start + msecs; ... |
void | sleep(long msecs, boolean busy_sleep) On most UNIX systems, the minimum sleep time is 10-20ms. if (!busy_sleep) { sleep(msecs); return; long start = System.currentTimeMillis(); long stop = start + msecs; while (stop > start) { start = System.currentTimeMillis(); ... |
boolean | sleep(long sleepTime) sleep try { Thread.sleep(sleepTime); return true; } catch (InterruptedException e) { Thread.currentThread().interrupt(); return false; |
void | sleep(long sleepTime) Puts the current thread to sleep for the specified amount of time. Thread currentThread = Thread.currentThread(); try { Thread.sleep(sleepTime); } catch (InterruptedException e) { e.printStackTrace(); currentThread.interrupt(); |
void | sleep(long time) sleep try { Thread.sleep(time); } catch (InterruptedException e) { e.printStackTrace(); |
void | sleep(long time) Since sleeps are sometimes necessary, this makes an easy way to ignore InterruptedException's. try { Thread.sleep(time); } catch (InterruptedException e) { Thread.currentThread().interrupt(); |
void | sleep(long time) Pauses for a given number of milliseconds try { Thread.sleep(time); } catch (InterruptedException e) { |