Class ThreadLocalRandom

java.lang.Object
java.util.Random
java.util.concurrent.ThreadLocalRandom

public class ThreadLocalRandom extends Random
  • Method Summary

    Modifier and Type
    Method
    Description
     
    double
    nextDouble(double bound)
     
    double
    nextDouble(double origin, double bound)
     
    int
    nextInt(int origin, int bound)
     
    long
    nextLong(long bound)
     
    long
    nextLong(long origin, long bound)
     
    void
    setSeed(long seed)
    Sets the seed of this random number generator using a single long seed.

    Methods inherited from class Random

    next, nextBoolean, nextBytes, nextDouble, nextFloat, nextInt, nextInt, nextLong
    Modifier and Type
    Method
    Description
    protected int
    next(int bits)
    Generates the next pseudorandom number.
    boolean
     
    void
    nextBytes(byte[] bytes)
     
    double
    Returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence.
    float
    Returns the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from this random number generator's sequence.
    int
    Returns the next pseudorandom, uniformly distributed int value from this random number generator's sequence.
    int
    nextInt(int n)
    Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.
    long
    Returns the next pseudorandom, uniformly distributed long value from this random number generator's sequence.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected Object
     
    boolean
    Indicates whether some other object is "equal to" this one.
    final Class
    Returns the runtime class of an object.
    int
    Returns a hash code value for the object.
    final void
    Wakes up a single thread that is waiting on this object's monitor.
    final void
    Wakes up all threads that are waiting on this object's monitor.
    Returns a string representation of the object.
    final void
    Causes current thread to wait until another thread invokes the method or the method for this object.
    final void
    wait(long timeout)
    Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
    final void
    wait(long timeout, int nanos)
    Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
  • Method Details

    • current

      public static ThreadLocalRandom current()
    • setSeed

      public void setSeed(long seed)
      Description copied from class: Random
      Sets the seed of this random number generator using a single long seed. The general contract of setSeed is that it alters the state of this random number generator object so as to be in exactly the same state as if it had just been created with the argument seed as a seed. The method setSeed is implemented by class Random as follows: synchronized public void setSeed(long seed) { this.seed = (seed ^ 0x5DEECE66DL) & ((1L invalid input: '<'invalid input: '<' 48) - 1); } The implementation of setSeed by class Random happens to use only 48 bits of the given seed. In general, however, an overriding method may use all 64 bits of the long argument as a seed value.
      Overrides:
      setSeed in class Random
    • nextInt

      public int nextInt(int origin, int bound)
    • nextLong

      public long nextLong(long bound)
    • nextLong

      public long nextLong(long origin, long bound)
    • nextDouble

      public double nextDouble(double bound)
    • nextDouble

      public double nextDouble(double origin, double bound)