Here you can find the source of sleep(long millis)
public static void sleep(long millis)
//package com.java2s; /*/*from w w w .ja v a2 s .c o m*/ * Copyright (c) 2014 aleon GmbH. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Markus Rathgeb - initial API and implementation and/or initial documentation */ public class Main { public static void sleep(long millis) { long start; long end; long remaining = millis; do { start = System.nanoTime(); try { Thread.sleep(remaining); remaining = 0; } catch (InterruptedException ex) { end = System.nanoTime(); remaining -= (end - start) / 1000000; } } while (remaining > 0); } }