public class SynchronizedRandomGenerator extends Object implements org.apache.commons.math3.random.RandomGenerator, Serializable
RandomGenerator
implementation can be thread-safe if it
is used through an instance of this class.
This is achieved by enclosing calls to the methods of the actual
generator inside the overridden synchronized
methods of this
class.Constructor and Description |
---|
SynchronizedRandomGenerator(org.apache.commons.math3.random.RandomGenerator rng)
Creates a synchronized wrapper for the given
RandomGenerator
instance. |
Modifier and Type | Method and Description |
---|---|
boolean |
nextBoolean() |
void |
nextBytes(byte[] bytes) |
double |
nextDouble() |
float |
nextFloat() |
double |
nextGaussian() |
int |
nextInt() |
int |
nextInt(int n) |
long |
nextLong() |
void |
setSeed(int seed) |
void |
setSeed(int[] seed) |
void |
setSeed(long seed) |
public SynchronizedRandomGenerator(org.apache.commons.math3.random.RandomGenerator rng)
RandomGenerator
instance.rng
- Generator whose methods will be called through
their corresponding overridden synchronized version.
To ensure thread-safety, the wrapped generator must
not be used directly.public void setSeed(int seed)
setSeed
in interface org.apache.commons.math3.random.RandomGenerator
public void setSeed(int[] seed)
setSeed
in interface org.apache.commons.math3.random.RandomGenerator
public void setSeed(long seed)
setSeed
in interface org.apache.commons.math3.random.RandomGenerator
public void nextBytes(byte[] bytes)
nextBytes
in interface org.apache.commons.math3.random.RandomGenerator
public int nextInt()
nextInt
in interface org.apache.commons.math3.random.RandomGenerator
public int nextInt(int n)
nextInt
in interface org.apache.commons.math3.random.RandomGenerator
public long nextLong()
nextLong
in interface org.apache.commons.math3.random.RandomGenerator
public boolean nextBoolean()
nextBoolean
in interface org.apache.commons.math3.random.RandomGenerator
public float nextFloat()
nextFloat
in interface org.apache.commons.math3.random.RandomGenerator
public double nextDouble()
nextDouble
in interface org.apache.commons.math3.random.RandomGenerator
public double nextGaussian()
nextGaussian
in interface org.apache.commons.math3.random.RandomGenerator
Copyright © 2015. All rights reserved.