Here you can find the source of sleep(long millis)
public static void sleep(long millis)
//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); } }