List of utility methods to do Sleep
void | sleepBeforeRetry(int attemptNumber) Used in case we need to re-submit request to AWS when it throws 'AWS Error Code: ServiceUnavailable, AWS Error Message: Service AmazonSimpleDB is currently unavailable. long sleepMS; if (attemptNumber < 5) { sleepMS = 100; } else if (attemptNumber < 10) { sleepMS = 1000; } else if (attemptNumber < 15) { sleepMS = 5000; } else if (attemptNumber < 20) { ... |
void | sleepButInterruptable(long msecs) sleep But Interruptable Thread.sleep(msecs); |
void | sleepCurrentThread() sleep Current Thread try { Thread.sleep(1000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); |
void | sleepDeep(long millis) Sleep, suppressing exceptions try { Thread.sleep(millis); } catch (InterruptedException e) { |
void | sleepExp(int countFailures) Implements simple exponential sleep based on number of failures (count). long ms = (long) (msMinSleep * Math.pow(countFailures, 1.5)); sleepMs(Math.min(ms, msMaxSleep)); |
void | sleepFixed(int milliSecond) Put the calling thread to sleep. final long endingTime = System.currentTimeMillis() + milliSecond; long remainingTime = milliSecond; while (remainingTime > 0) { try { Thread.sleep(remainingTime); } catch (InterruptedException ignore) { remainingTime = endingTime - System.currentTimeMillis(); ... |
void | sleepFor(int delay ) Sleeps the current thread for the given amount of milliseconds. int x = 0; while (x < delay) { x += SLEEP_DELAY; try { Thread.sleep(SLEEP_DELAY); } catch (InterruptedException ie) { |
void | sleepFor(int sleepDurationInMilliseconds) Attempts to sleep for a specified period try { Thread.sleep(sleepDurationInMilliseconds); } catch (InterruptedException e) { System.out.println("Error sleeping thread for: " + sleepDurationInMilliseconds); |
void | sleepFor(long millis) Sleeps at least until the specified amount of time has passed, uninterruptibly. sleepUntil(System.currentTimeMillis() + millis); |
void | sleepForAuditGranularity() For audit, make sure event dates don't have the same millisecond. Thread.sleep(2); |