Module java.base

Interface RandomGenerator.ArbitrarilyJumpableGenerator

All Superinterfaces:
RandomGenerator, RandomGenerator.JumpableGenerator, RandomGenerator.LeapableGenerator, RandomGenerator.StreamableGenerator
Enclosing interface:
RandomGenerator

public static interface RandomGenerator.ArbitrarilyJumpableGenerator extends RandomGenerator.LeapableGenerator
This interface is designed to provide a common protocol for objects that generate sequences of pseudorandom values and can easily jump forward, by an arbitrary amount, to a distant point in the state cycle.

Ideally, all RandomGenerator.ArbitrarilyJumpableGenerator objects produced by iterative jumping from a single original RandomGenerator.ArbitrarilyJumpableGenerator object are statistically independent of one another and individually uniform, provided that they do not traverse overlapping portions of the state cycle. In practice, one must settle for some approximation to independence and uniformity. In particular, a specific implementation may assume that each generator in a stream produced by the jump() method is used to produce a number of values no larger than the jump distance specified. Implementors are advised to use algorithms whose period is at least 2127.

For many applications, it suffices to jump forward by a power of two or some small multiple of a power of two, but this power of two may not be representable as a long value. To avoid the use of BigInteger values as jump distances, double values are used instead.

Methods are provided to perform a single jump operation and also to produce a stream of generators produced from the original by iterative copying and jumping of internal state. A typical strategy for a multithreaded application is to create a single RandomGenerator.ArbitrarilyJumpableGenerator object, call its jump() method exactly once, and then parcel out generators from the resulting stream, one to each thread. However, each generator produced also has type RandomGenerator.ArbitrarilyJumpableGenerator; with care, different jump distances can be used to traverse the entire state cycle in various ways.

Objects that implement RandomGenerator.ArbitrarilyJumpableGenerator are typically not cryptographically secure. Consider instead using SecureRandom to get a cryptographically secure pseudo-random number generator for use by security-sensitive applications.