Here you can find the source of sleep(int toSleep)
public static void sleep(int toSleep)
//package com.java2s; //License from project: Open Source License public class Main { public static void sleep(int toSleep) { try {/*from w w w .ja v a 2 s.c om*/ long start = System.currentTimeMillis(); Thread.sleep(toSleep); long now; while (start + toSleep > (now = System.currentTimeMillis())) Thread.sleep(start + toSleep - now); } catch (InterruptedException e) { e.printStackTrace(); } } }