Class FastRandom

  • All Implemented Interfaces:
    Serializable

    public class FastRandom
    extends Random
    A fast version of Random, which extends from it but eliminates thread safety. ThreadLocalRandom has a similar performance, but by design it doesn't allow specifying the seed. Usage of 3rd patry implementations is also possible, but this implementation is guaranteed to have the same behavior of java.util.Random, given the same seed.
    Author:
    Eyal Schneider
    See Also:
    Serialized Form
    • Constructor Detail

      • FastRandom

        public FastRandom()
        Constructor Uses a seed derived from the clock
      • FastRandom

        public FastRandom​(long seed)
        Constructor
        Parameters:
        seed - The seed value to use
    • Method Detail

      • next

        protected int next​(int bits)
        Overrides:
        next in class Random