Documentation of 'edu.cornell.lassp.houle.RngPack.RandomSynchronized' Java class
RandomSynchronized
edu.cornell.lassp.houle.RngPack

Class RandomSynchronized

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable


    public abstract class RandomSynchronized
    extends RandomElement
    implements java.io.Serializable
    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.

    See Also:
    RandomElement, Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      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 java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RandomSynchronized

        public RandomSynchronized(RandomElement rng)
    • Method Detail

      • raw

        public double raw()
        Synchronized the raw() method, which is generally not threadsafe.
        Specified by:
        raw in class RandomElement
        Returns:
        a random double in the range [0,1]
        See Also:
        RandomJava
      • raw

        public void raw(double[] d,
                        int n)
        This method probably isn't threadsafe in implementations, so it's synchronized
        Overrides:
        raw in class RandomElement
        Parameters:
        d - array to be filled with doubles
        n - number of doubles to generate
      • choose

        public int choose(int lo,
                          int hi)
        Wrapped so generators can override.
        Overrides:
        choose in class RandomElement
        Parameters:
        lo - lower limit of range
        hi - upper limit of range
        Returns:
        a random integer in the range lo, lo+1, ... ,hi
      • gaussian

        public double gaussian()
        Must be synchronized because state is stored in BMoutput
        Overrides:
        gaussian in class RandomElement
        Returns:
        a random real with a gaussian distribution, standard deviation

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.