Java Sleep sleep(long millis)

Here you can find the source of sleep(long millis)

Description

The function causes the currently executing thread to sleep.

License

Open Source License

Parameter

Parameter Description
millis - the length of time to sleep in milliseconds

Declaration

public static final void sleep(long millis) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from ww w.  ja v a  2s. c om
     * The function causes the currently executing thread to sleep.
     * Exceptions thrown by Thread.sleep() are handled here. This way, code calls to sleep() are cleaner.
     * @param millis - the length of time to sleep in milliseconds
     */
    public static final void sleep(long millis) {
        try {
            Thread.sleep(millis);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            // Because if sleep throws that exception, the thread is no longer interrupted
        }
    }
}

Related

  1. sleep(long millis)
  2. sleep(long millis)
  3. sleep(long millis)
  4. sleep(long millis)
  5. sleep(long millis)
  6. sleep(long millis)
  7. sleep(long millis)
  8. sleep(Long millis)
  9. sleep(long millis)