Java Sleep sleep(long millis)

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

Description

sleep

License

Open Source License

Declaration

public static void sleep(long millis) 

Method Source Code

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

public class Main {
    public static void sleep(long millis) {
        if (millis < 0) {
            throw new IllegalArgumentException();
        }/*from  w  w w .j  a v  a 2s .  co m*/

        long start = System.currentTimeMillis();
        long elapsed = 0;

        do {
            try {
                Thread.sleep(millis - elapsed);
            } catch (InterruptedException e) {
                // Sleeping was interrupted. Do nothing.
            }
            elapsed = System.currentTimeMillis() - start;
        } while (elapsed < millis);
    }
}

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)