|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.cornell.lassp.houle.RngPack.RandomElement
edu.cornell.lassp.houle.RngPack.RandomSynchronized
RandomSynchronized is a wrapper class that makes a random number generator safe for multi-threaded operation by serializing access in time. For high-performance applications, it is better for each thread to have it's own random number generator. Note this class is declared serializable, but serialization won't be successful if it's wrapping a non-serializable generator.
Source code is available.
RandomElement
,
Serialized FormConstructor Summary | |
RandomSynchronized(RandomElement rng)
|
Method Summary | |
int |
choose(int lo,
int hi)
Wrapped so generators can override. |
double |
gaussian()
Must be synchronized because state is stored in BMoutput |
double |
raw()
Synchronized the raw() method, which is generally not threadsafe. |
void |
raw(double[] d,
int n)
This method probably isn't threadsafe in implementations, so it's synchronized |
Methods inherited from class edu.cornell.lassp.houle.RngPack.RandomElement |
choose, clone, coin, coin, gaussian, powlaw, raw, uniform |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public RandomSynchronized(RandomElement rng)
Method Detail |
public double raw()
raw
in class RandomElement
RandomJava
public void raw(double[] d, int n)
raw
in class RandomElement
d
- array to be filled with doublesn
- number of doubles to generatepublic int choose(int lo, int hi)
choose
in class RandomElement
lo
- lower limit of rangehi
- upper limit of range
public double gaussian()
gaussian
in class RandomElement
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |