Java Random Long randomSleep(long ms)

Here you can find the source of randomSleep(long ms)

Description

Sleep for a short random amount of time

License

Open Source License

Parameter

Parameter Description
ms max time

Declaration

public static void randomSleep(long ms) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from   ww w  . j  a v a 2 s.  c om*/
     * Sleep for a short random amount of time
     * 
     * @param ms max time
     */
    public static void randomSleep(long ms) {
        try {
            Thread.sleep((long) (ms * Math.random()));
        } catch (InterruptedException e) {
        }
    }
}

Related

  1. randomLong()
  2. randomLong()
  3. randomLong(long min, long max)
  4. randomLong(long x, long y)
  5. randomLongWithMinMax(long min, long max)
  6. randomStr(long strLen)
  7. randomStr(long strLen)
  8. randPosLong()
  9. secureRandomLong()