Class ConcurrentCachedRLG

All Implemented Interfaces:
RandomLongGenerator, RandomNumberGenerator, Seedable

public class ConcurrentCachedRLG extends Object implements RandomLongGenerator
This is a fast thread-safe wrapper for random long generators. This class is backed by ConcurrentCachedGenerator.
  • Constructor Details

    • ConcurrentCachedRLG

      public ConcurrentCachedRLG(RandomLongGenerator uniform, int cacheSize)
      Constructs a new instance which wraps the given random long generator and uses a cache of the specified size. A larger cache will make the simulation slightly faster at the expense of increased memory usage, but can lead to unnecessary computation of values at the tail.
      uniform - the underlying generator
      cacheSize - the cache size
      See Also:
    • ConcurrentCachedRLG

      public ConcurrentCachedRLG(RandomLongGenerator uniform)
      Construct a new instance which wraps the given random long generator and uses a cache which has 1000 entries per available core.
      uniform - the underlying generator
  • Method Details

    • nextLong

      public long nextLong()
      Description copied from interface: RandomLongGenerator
      Get the next random long.
      Specified by:
      nextLong in interface RandomLongGenerator
      the next random long
    • seed

      public void seed(long... seeds)
      Delegate to the underlying random long generator. Note: this method is NOT thread-safe.
      Specified by:
      seed in interface Seedable
      seeds - the seeds
    • nextDouble

      public double nextDouble()
      Description copied from interface: RandomNumberGenerator
      Get the next random double.
      Specified by:
      nextDouble in interface RandomNumberGenerator
      the next random number