com.datumbox.framework.common.utilities
Class RandomGenerator
- java.lang.Object
-
- com.datumbox.framework.common.utilities.RandomGenerator
-
public class RandomGenerator extends java.lang.ObjectThe RandomGenerator generates Random objects that can be read and modified by the same thread. The class can be configured with a globalSeed that is used to initialize all the generated Random objects.
-
-
Constructor Summary
Constructors Constructor and Description RandomGenerator()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static java.lang.LonggetGlobalSeed()Getter for the global seed.static java.util.RandomgetThreadLocalRandom()Returns a Random object which is stored as ThreadLocal variable and as a result each Thread has an independent copy of this variable.static java.util.RandomgetThreadLocalRandomUnseeded()Returns a Random object which is local for the thread but unseeded.static voidsetGlobalSeed(java.lang.Long globalSeed)Setter for the global seed.
-
-
-
Method Detail
-
getGlobalSeed
public static java.lang.Long getGlobalSeed()
Getter for the global seed. The global seed affects the initial seeding of all the Random objects that are generated by this class.- Returns:
-
setGlobalSeed
public static void setGlobalSeed(java.lang.Long globalSeed)
Setter for the global seed. The global seed affects the initial seeding of all the Random objects that are generated by this class. Changing the global seed does not affect the Random objects that have already been generated. If you wish to change the seed of an already initialized Random object use the setSeed() method of that object.- Parameters:
globalSeed-
-
getThreadLocalRandom
public static java.util.Random getThreadLocalRandom()
Returns a Random object which is stored as ThreadLocal variable and as a result each Thread has an independent copy of this variable. When the Random objects are initialized, they seeded with the global seed (if not null).- Returns:
-
getThreadLocalRandomUnseeded
public static java.util.Random getThreadLocalRandomUnseeded()
Returns a Random object which is local for the thread but unseeded.- Returns:
-
-
DataMelt 3.0 © DataMelt by jWork.ORG