Java Utililty Methods Sleep

List of utility methods to do Sleep

Description

The list of methods to do Sleep are organized into topic(s).

Method

voidsleep(final int timeMs)
sleep
new Thread() {
    public void run() {
        try {
            sleep(timeMs);
        } catch (InterruptedException e) {
            e.printStackTrace();
        super.run();
...
voidsleep(final long miliseconds)
sleep
try {
    Thread.sleep(miliseconds);
} catch (Exception e) {
    e.printStackTrace();
booleansleep(final long millis)
sleep
try {
    if (millis > 0) {
        Thread.sleep(millis);
} catch (final InterruptedException e) {
    Thread.currentThread().interrupt();
    return false;
return true;
voidsleep(final long milliseconds)
Make thread call it sleep for specified time in milliseconds
try {
    Thread.sleep(milliseconds);
} catch (final Exception exception) {
booleansleep(final long milliseconds)
sleep
try {
    Thread.sleep(milliseconds);
    return true;
} catch (InterruptedException ignore) {
    return false;
voidsleep(int delay)
sleep
try {
    final long millis = (long) (Math.random() * delay);
    Thread.sleep(millis);
} catch (final InterruptedException e) {
voidsleep(int i, String s)
sleep
System.out.println(s);
try {
    Thread.sleep(i * 1000);
} catch (InterruptedException e) {
    throw new RuntimeException(e.getMessage());
voidsleep(int millis)
sleep
try {
    Thread.sleep(millis);
} catch (InterruptedException shouldNotHappen) {
    throw new IllegalStateException(shouldNotHappen);
voidsleep(int millis)
Cause this thread to sleep for specified amount of time while other threads run.
if (millis > 0) {
    try {
        Thread.sleep(millis);
    } catch (InterruptedException e) {
        e.printStackTrace();
voidsleep(int millis)
Sleep without exception.
try {
    Thread z = Thread.currentThread();
    z.sleep(millis);
} catch (Exception e) {
    System.err.println(Thread.currentThread().getName() + " error " + e.getMessage());