Java Sleep sleepForTimestamp()

Here you can find the source of sleepForTimestamp()

Description

sleep For Timestamp

License

Open Source License

Declaration

public static void sleepForTimestamp() 

Method Source Code

//package com.java2s;
/*/*ww  w  . ja v  a  2s.  c  o  m*/
 * ====================================================================
 * Copyright (c) 2004-2010 TMate Software Ltd.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://svnkit.com/license.html
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 * ====================================================================
 */

public class Main {
    private static volatile boolean ourIsSleepForTimeStamp = true;

    public static void sleepForTimestamp() {
        if (!ourIsSleepForTimeStamp) {
            return;
        }
        long time = System.currentTimeMillis();
        time = 1100 - (time - (time / 1000) * 1000);
        try {
            Thread.sleep(time);
        } catch (InterruptedException e) {
            //
        }
    }
}

Related

  1. sleepForever()
  2. sleepForIOCatchup()
  3. sleepForReal(long time)
  4. sleepForSecs(double numSecs)
  5. sleepForSomeTime(long milliseconds)
  6. sleepIgnoreInterupt(long millis)
  7. sleepInterruptible(long timeMillis)
  8. sleepMillis(int milliseconds)
  9. sleepMillis(long millis)