class SplittableRandom

Jeff Hain jeffhain at
Thu Jul 11 21:29:41 UTC 2013

Doug Lea wrote:
>>    new Subtask(new MySequentialRandom(currentTaskRandom.nextLong())).fork()
>One way to think of SplittableRandom is that it makes your idea
>behind this code actually work. As it stands, if you were to do
>this with java.util.Random, both would generate the same sequence.

What I was worrying about is having a new API, for a behavior that
could be obtained with an old one, but indeed this new API helps
people not screw up as they would tend to if using the old one
(and especially its default implementation), and it should be
easy to make an adapter extending Random and have existing code
use SplittableRandom through it.
Also not extending Random saves memory and makes things faster
(no method override).

>Singling out a particular algorithm/method
>for Gaussian stands mostly as an accident of history
>in java.util.Random.

Yes, that was just in case you were going to make
SplittableRandom extend or at least imitate
Random at some point, for convenience (like
for nextDouble()).


More information about the core-libs-dev mailing list