Is java.util.Random deterministic given the same seed and JVM version?

Viewed 38

I'm investigating the elusive Spark's indeterminacy exception, and I suspect that java.util.Random is not always deterministic.

I wonder if anyone knows if java.util.Random is deterministic assuming the seed and JVM version are identical.

Thank you.

3 Answers

java.util.Random specifies the exact algorithm it uses to generate random numbers. As a result, it is deterministic assuming the same seed -- whether or not the JVM version is identical.

From the docs:

If two instances of Random are created with the same seed, and the same sequence of method calls is made for each, they will generate and return identical sequences of numbers.

Related