Java Milliseconds safeSleepMillis(long milliseconds)

Here you can find the source of safeSleepMillis(long milliseconds)

Description

Sleep for specified number of milliseconds without having to bother catching the InterruptedException potentially thrown by the regular sleep method.

License

Apache License

Parameter

Parameter Description
milliseconds the minimum number of milliseconds that the calling thread should be suspended for (the thread could conceivably be suspended for an arbitrary number of additional milliseconds depending upon far too many factors to enumerate here).

Declaration


public static void safeSleepMillis(long milliseconds) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*from  w ww.ja v  a2 s  .  c  o m*/
     * Sleep for specified number of milliseconds without having to bother catching the InterruptedException potentially
     * thrown by the regular sleep method.
     *
     * @param milliseconds the minimum number of milliseconds that the calling thread should be suspended for (the
     *                     thread could conceivably be suspended for an arbitrary number of additional milliseconds
     *                     depending upon far too many factors to enumerate here).
     */

    public static void safeSleepMillis(long milliseconds) {

        try {

            Thread.sleep(milliseconds);

        } catch (InterruptedException e) {

            //noinspection CallToPrintStackTrace
            e.printStackTrace();

        }

    }
}

Related

  1. reverseTimeMillis(long currentTimeMillis)
  2. rollMockClockMillis(long millis)
  3. roundMicrosToMillis(String micros)
  4. roundMillisWithSecondPrecision(long l)
  5. roundTimeToTheNearestSecondInMilliseconds(long timeInMilliseconds)
  6. samples2millis(long samples, double sampleRate)
  7. samplesToMilliseconds(int sampleRate, int samples)
  8. setGlobalDebugMillis(int millis)
  9. setMilliseconds(Date date, int amount)