Here you can find the source of ensureSleepMillis(long millis)
public static void ensureSleepMillis(long millis) throws InterruptedException
//package com.java2s; //License from project: Apache License public class Main { /**/*from w w w . j a v a 2 s .c o m*/ * Ensures the current thread sleeps at least the given milliseconds before * returning from this method. */ public static void ensureSleepMillis(long millis) throws InterruptedException { if (millis < 1) return; long now = System.currentTimeMillis(); final long targetTime = now + millis; do { Thread.sleep(millis); millis = targetTime - System.currentTimeMillis(); } while (millis > 0); } }