Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * 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
 *
 * Note for all commercial users of this library:
 * Please contact the EnOcean Alliance (http://www.enocean-alliance.org/)
 * about a possible requirement to become member of the alliance to use the
 * EnOcean protocol implementations.
 *
 * Contributors:
 *    Markus Rathgeb - initial API and implementation and/or initial documentation
 */

public class Main {
    public static void sleep(final long millis) {
        long start;
        long end;
        long remaining = millis;
        do {
            start = System.nanoTime();
            try {
                Thread.sleep(remaining);
                remaining = 0;
            } catch (final InterruptedException ex) {
                end = System.nanoTime();
                remaining -= (end - start) / 1000000;
            }
        } while (remaining > 0);
    }
}