## net.i2p.util
Class PooledRandomSource

    java.lang.Object
      java.util.Random
          java.security.SecureRandom
              net.i2p.util.RandomSource
                  net.i2p.util.PooledRandomSource

All Implemented Interfaces:
  java.io.Serializable, EntropyHarvester

Direct Known Subclasses:
  DummyPooledRandomSource

    public class PooledRandomSource

extends RandomSource

Maintain a set of PRNGs to feed the apps

See Also:
  Serialized Form

Field Summary
`protected int` `_nextPool`
`protected RandomSource[]` `_pool`
`static int` `POOL_SIZE`
`static java.lang.String` `PROP_BUFFER_SIZE` How much random data will we precalculate and feed from (as opposed to on demand reseeding, etc).

Fields inherited from class net.i2p.util.RandomSource
`_context`

Constructor Summary
`PooledRandomSource(I2PAppContext context)`

Method Summary
`EntropyHarvester` `harvester()`
`protected void` `initializePool(I2PAppContext context)`
`static void` `main(java.lang.String[] args)`
`boolean` `nextBoolean()` override as synchronized, for those JVMs that don't always pull via nextBytes (cough ibm)
`void` `nextBytes(byte[] buf)` override as synchronized, for those JVMs that don't always pull via nextBytes (cough ibm)
`double` `nextDouble()` override as synchronized, for those JVMs that don't always pull via nextBytes (cough ibm)
`float` `nextFloat()` override as synchronized, for those JVMs that don't always pull via nextBytes (cough ibm)
`double` `nextGaussian()` override as synchronized, for those JVMs that don't always pull via nextBytes (cough ibm)
`int` `nextInt()` override as synchronized, for those JVMs that don't always pull via nextBytes (cough ibm)
`int` `nextInt(int n)` According to the java docs (http://java.sun.com/j2se/1.4.1/docs/api/java/util/Random.html#nextInt(int)) nextInt(n) should return a number between 0 and n (including 0 and excluding n).
`long` `nextLong()` override as synchronized, for those JVMs that don't always pull via nextBytes (cough ibm)
`long` `nextLong(long n)` Like the modified nextInt, nextLong(n) returns a random number from 0 through n, including 0, excluding n.

Methods inherited from class net.i2p.util.RandomSource
`feedEntropy, feedEntropy, getInstance, initSeed, loadSeed, saveSeed, writeSeed`

Methods inherited from class java.security.SecureRandom
`generateSeed, getAlgorithm, getInstance, getInstance, getInstance, getProvider, getSeed, next, setSeed, setSeed`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### _pool

    protected RandomSource[] _pool

### _nextPool

    protected volatile int _nextPool

### POOL_SIZE

    public static final int POOL_SIZE

See Also:
  Constant Field Values

### PROP_BUFFER_SIZE

    public static final java.lang.String PROP_BUFFER_SIZE

  How much random data will we precalculate and feed from (as opposed to on demand reseeding, etc). If this is not set, a default will be used (4MB), or if it is set to 0, no buffer will be used, otherwise the amount specified will be allocated across the pooled PRNGs.

  See Also:
    Constant Field Values

Constructor Detail

### PooledRandomSource

    public PooledRandomSource(I2PAppContext context)

Method Detail

### initializePool

    protected void initializePool(I2PAppContext context)

### nextInt

    public int nextInt(int n)

  According to the java docs (http://java.sun.com/j2se/1.4.1/docs/api/java/util/Random.html#nextInt(int)) nextInt(n) should return a number between 0 and n (including 0 and excluding n). However, their pseudocode, as well as sun's, kaffe's, and classpath's implementation INCLUDES NEGATIVE VALUES. WTF. Ok, so we're going to have it return between 0 and n (including 0, excluding n), since thats what it has been used for.

  Overrides:
    `nextInt` in class `RandomSource`

### nextLong

    public long nextLong(long n)

  Like the modified nextInt, nextLong(n) returns a random number from 0 through n, including 0, excluding n.

  Overrides:
    `nextLong` in class `RandomSource`

### nextBoolean

    public boolean nextBoolean()

  override as synchronized, for those JVMs that don't always pull via nextBytes (cough ibm)

  Overrides:
    `nextBoolean` in class `RandomSource`

### nextBytes

    public void nextBytes(byte[] buf)

  override as synchronized, for those JVMs that don't always pull via nextBytes (cough ibm)

  Overrides:
    `nextBytes` in class `RandomSource`

### nextDouble

    public double nextDouble()

  override as synchronized, for those JVMs that don't always pull via nextBytes (cough ibm)

  Overrides:
    `nextDouble` in class `RandomSource`

### nextFloat

    public float nextFloat()

  override as synchronized, for those JVMs that don't always pull via nextBytes (cough ibm)

  Overrides:
    `nextFloat` in class `RandomSource`

### nextGaussian

    public double nextGaussian()

  override as synchronized, for those JVMs that don't always pull via nextBytes (cough ibm)

  Overrides:
    `nextGaussian` in class `RandomSource`

### nextInt

    public int nextInt()

  override as synchronized, for those JVMs that don't always pull via nextBytes (cough ibm)

  Overrides:
    `nextInt` in class `RandomSource`

### nextLong

    public long nextLong()

  override as synchronized, for those JVMs that don't always pull via nextBytes (cough ibm)

  Overrides:
    `nextLong` in class `RandomSource`

### harvester

    public EntropyHarvester harvester()

  Overrides:
    `harvester` in class `RandomSource`

### main

    public static void main(java.lang.String[] args)