List of utility methods to do Sleep
void | sleepNoShit(long nanos) sleep No Shit if (nanos < 0) return; try { Thread.sleep(nanos / 1000000, (int) (nanos % 1000000)); } catch (InterruptedException e) { |
void | sleepNotException(long millis) sleep Not Exception try { Thread.sleep(millis); } catch (Exception ex) { System.out.println("sleep ex," + ex.getClass().getSimpleName()); |
void | sleepNoThrow(long timeoutMs) sleep No Throw try { Thread.sleep(timeoutMs); } catch (InterruptedException e) { |
void | sleepNs(int ns) sleep Ns long start = System.nanoTime(); long end = 0; do { end = System.nanoTime(); } while (start + ns >= end); |
void | sleepNS(long ns) sleep NS if (ns <= 0) { throwIfInterrupted(); return; long millis = ns / 1000000; int nanos = (int) (ns - millis * 1000000); Thread.sleep(millis, nanos); |
void | sleepOrCry(long timeToWait) sleep Or Cry sleepOrCry(timeToWait, null); |
void | sleepPeriod(double period) sleep Period try { long millis = (long) (period * 1000); int nanos = (int) ((period * 1000 - millis) * 1000000); Thread.sleep(millis, nanos); } catch (InterruptedException e) { throw new RuntimeException(e); |
void | sleepQuietly(int millis) sleep Quietly try { Thread.sleep(millis); } catch (InterruptedException e) { throw new RuntimeException(e); |
boolean | sleepQuietly(long millis) Invokes Thread.sleep(long), catching any InterruptedException that is thrown. try { Thread.sleep(millis); } catch (InterruptedException e) { return false; return true; |
long | sleepQuietly(long millis) Sleeps for the specified number of milliseconds, catching and ignoring any InterruptedException .
long start = System.currentTimeMillis(); try { Thread.sleep(millis); } catch (InterruptedException ignored) { return System.currentTimeMillis() - start; |