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) { long sleepStartedAt = System.currentTimeMillis(); try {/* ww w . j a v a2 s. c om*/ Thread.sleep(millis); } catch (InterruptedException exception) { long sleepInterruptedAt = System.currentTimeMillis(); long remainingSleepTime = millis - (sleepInterruptedAt - sleepStartedAt); sleep(remainingSleepTime); } } }