Here you can find the source of sleepForReal(long time)
public static void sleepForReal(long time) throws InterruptedException
//package com.java2s; //License from project: Open Source License public class Main { public static void sleepForReal(long time) throws InterruptedException { long end = System.currentTimeMillis() + time; while (true) { long now = System.currentTimeMillis(); if (now >= end) return; Thread.sleep(end - now); }/*from ww w .ja v a 2 s . com*/ } }