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.
| Modifier and Type | Field and Description |
|---|---|
| private final RandomGenerator | wrapped
Object to which all calls will be delegated. |
| Access | Constructor and Description |
|---|---|
| public | SynchronizedRandomGenerator(RandomGenerator
Generator whose methods will be called through
their corresponding overridden synchronized version.
To ensure thread-safety, the wrapped generator must
not be used directly. rng)Creates a synchronized wrapper for the given |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized boolean | nextBoolean()
Implements org. Returns the next pseudorandom, uniformly distributed
|
| public synchronized void | nextBytes(byte[]
the non-null byte array in which to put the
random bytes bytes)Implements org. Generates random bytes and places them into a user-supplied byte array. |
| public synchronized double | nextDouble()
Implements org. Returns the next pseudorandom, uniformly distributed
|
| public synchronized float | nextFloat()
Implements org. Returns the next pseudorandom, uniformly distributed |
| public synchronized double | nextGaussian()
Implements org. Returns the next pseudorandom, Gaussian ("normally") distributed
|
| public synchronized int | nextInt()
Implements org. Returns the next pseudorandom, uniformly distributed |
| public synchronized int | nextInt(int
the bound on the random number to be returned. Must be
positive. n)Implements org. Returns a pseudorandom, uniformly distributed |
| public synchronized long | nextLong()
Implements org. Returns the next pseudorandom, uniformly distributed |
| public synchronized void | setSeed(int
the seed value seed)Implements org. Sets the seed of the underlying random number generator using an
|
| public synchronized void | setSeed(int[]
the seed value seed)Implements org. Sets the seed of the underlying random number generator using an
|
| public synchronized void | setSeed(long
the seed value seed)Implements org. Sets the seed of the underlying random number generator using a
|
| wrapped | back to summary |
|---|---|
| private final RandomGenerator wrapped Object to which all calls will be delegated. | |
| SynchronizedRandomGenerator | back to summary |
|---|---|
| public SynchronizedRandomGenerator(RandomGenerator rng) Creates a synchronized wrapper for the given
| |
| nextBoolean | back to summary |
|---|---|
| public synchronized boolean nextBoolean() Implements org. Doc from org. Returns the next pseudorandom, uniformly distributed
| |
| nextBytes | back to summary |
|---|---|
| public synchronized void nextBytes(byte[] bytes) Implements org. Doc from org. Generates random bytes and places them into a user-supplied byte array. The number of random bytes produced is equal to the length of the byte array.
| |
| nextDouble | back to summary |
|---|---|
| public synchronized double nextDouble() Implements org. Doc from org. Returns the next pseudorandom, uniformly distributed
| |
| nextFloat | back to summary |
|---|---|
| public synchronized float nextFloat() Implements org. Doc from org. Returns the next pseudorandom, uniformly distributed
| |
| nextGaussian | back to summary |
|---|---|
| public synchronized double nextGaussian() Implements org. Doc from org. Returns the next pseudorandom, Gaussian ("normally") distributed
| |
| nextInt | back to summary |
|---|---|
| public synchronized int nextInt() Implements org. Doc from org. Returns the next pseudorandom, uniformly distributed
| |
| nextInt | back to summary |
|---|---|
| public synchronized int nextInt(int n) Implements org. Doc from org. Returns a pseudorandom, uniformly distributed
| |
| nextLong | back to summary |
|---|---|
| public synchronized long nextLong() Implements org. Doc from org. Returns the next pseudorandom, uniformly distributed
| |
| setSeed | back to summary |
|---|---|
| public synchronized void setSeed(int seed) Implements org. Doc from org. Sets the seed of the underlying random number generator using an
Sequences of values generated starting with the same seeds should be identical.
| |
| setSeed | back to summary |
|---|---|
| public synchronized void setSeed(int[] seed) Implements org. Doc from org. Sets the seed of the underlying random number generator using an
Sequences of values generated starting with the same seeds should be identical.
| |
| setSeed | back to summary |
|---|---|
| public synchronized void setSeed(long seed) Implements org. Doc from org. Sets the seed of the underlying random number generator using a
Sequences of values generated starting with the same seeds should be identical.
| |