Package io.jenetics.prngine
Class XOR32ShiftRandom.ThreadSafe
- java.lang.Object
-
- java.util.Random
-
- io.jenetics.prngine.PRNG
-
- io.jenetics.prngine.Random32
-
- io.jenetics.prngine.XOR32ShiftRandom
-
- io.jenetics.prngine.XOR32ShiftRandom.ThreadSafe
-
- All Implemented Interfaces:
Serializable
- Enclosing class:
- XOR32ShiftRandom
public static class XOR32ShiftRandom.ThreadSafe extends XOR32ShiftRandom
This is a thread safe variation of the this PRNG—by synchronizing the random number generation.- Since:
- 1.0
- Version:
- 1.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.jenetics.prngine.XOR32ShiftRandom
XOR32ShiftRandom.Param, XOR32ShiftRandom.Shift, XOR32ShiftRandom.ThreadLocal, XOR32ShiftRandom.ThreadSafe
-
-
Field Summary
-
Fields inherited from class io.jenetics.prngine.XOR32ShiftRandom
SEED_BYTES
-
-
Constructor Summary
Constructors Constructor Description ThreadSafe()
Create a new PRNG instance withXOR32ShiftRandom.Param.DEFAULT
parameter and a safe seed.ThreadSafe(byte[] seed)
Create a new PRNG instance with the given parameter and seed.ThreadSafe(long seed)
Create a new PRNG instance withXOR32ShiftRandom.Param.DEFAULT
parameter and the given seed.ThreadSafe(XOR32ShiftRandom.Param param)
Create a new PRNG instance with the given parameter and a safe seedThreadSafe(XOR32ShiftRandom.Param param, byte[] seed)
Create a new PRNG instance with the given parameter and seed.ThreadSafe(XOR32ShiftRandom.Param param, long seed)
Create a new PRNG instance with the given parameter and seed.ThreadSafe(XOR32ShiftRandom.Shift shift, XOR32ShiftRandom.Param param, byte[] seed)
Create a new PRNG instance with the given shift, parameter and seed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
nextInt()
Force to explicitly override the Random.nexInt() method.void
setSeed(byte[] seed)
Set the seed value of the PRNG.void
setSeed(long seed)
-
Methods inherited from class io.jenetics.prngine.XOR32ShiftRandom
equals, hashCode, seedBytes, toString
-
Methods inherited from class io.jenetics.prngine.PRNG
nextDouble, nextDouble, nextFloat, nextFloat, nextInt, nextInt, nextLong, nextLong, nextLong, nextLong, seed, seed, seedBytes, seedBytes, seedBytes, seedBytes
-
-
-
-
Constructor Detail
-
ThreadSafe
public ThreadSafe(XOR32ShiftRandom.Shift shift, XOR32ShiftRandom.Param param, byte[] seed)
Create a new PRNG instance with the given shift, parameter and seed.- Parameters:
shift
- the shift strategy of the PRNGparam
- the parameter of the PRNG.seed
- the seed of the PRNG.- Throws:
NullPointerException
- if the givenshift
,param
orseed
isnull
.IllegalArgumentException
- if the given seed is shorter thanXOR32ShiftRandom.SEED_BYTES
-
ThreadSafe
public ThreadSafe(XOR32ShiftRandom.Param param, byte[] seed)
Create a new PRNG instance with the given parameter and seed.- Parameters:
param
- the parameter of the PRNG.seed
- the seed of the PRNG.- Throws:
NullPointerException
- if the givenparam
orseed
isnull
.IllegalArgumentException
- if the given seed is shorter thanXOR32ShiftRandom.SEED_BYTES
-
ThreadSafe
public ThreadSafe(XOR32ShiftRandom.Param param, long seed)
Create a new PRNG instance with the given parameter and seed.- Parameters:
seed
- the seed of the PRNG.param
- the parameter of the PRNG.- Throws:
NullPointerException
- if the givenparam
isnull
.
-
ThreadSafe
public ThreadSafe(XOR32ShiftRandom.Param param)
Create a new PRNG instance with the given parameter and a safe seed- Parameters:
param
- the PRNG parameter.- Throws:
NullPointerException
- if the givenparam
is null.
-
ThreadSafe
public ThreadSafe(byte[] seed)
Create a new PRNG instance with the given parameter and seed.- Parameters:
seed
- the seed of the PRNG.- Throws:
NullPointerException
- if the givenseed
isnull
.IllegalArgumentException
- if the given seed is shorter thanXOR32ShiftRandom.SEED_BYTES
-
ThreadSafe
public ThreadSafe(long seed)
Create a new PRNG instance withXOR32ShiftRandom.Param.DEFAULT
parameter and the given seed.- Parameters:
seed
- the seed of the PRNG
-
ThreadSafe
public ThreadSafe()
Create a new PRNG instance withXOR32ShiftRandom.Param.DEFAULT
parameter and a safe seed.
-
-
Method Detail
-
setSeed
public void setSeed(byte[] seed)
Description copied from class:XOR32ShiftRandom
Set the seed value of the PRNG.- Overrides:
setSeed
in classXOR32ShiftRandom
- Parameters:
seed
- the seed value.
-
setSeed
public void setSeed(long seed)
- Overrides:
setSeed
in classXOR32ShiftRandom
-
nextInt
public int nextInt()
Description copied from class:Random32
Force to explicitly override the Random.nexInt() method. All other methods of this class are implemented by calling this method.- Overrides:
nextInt
in classXOR32ShiftRandom
-
-