> On Oct 18, 2017, at 3:15 PM, Martin Buchholz <[email protected]> wrote:
> 
> Why not SplittableRandom?
> https://docs.oracle.com/javase/9/docs/api/java/util/SplittableRandom.html#nextLong-long-

In this particular case, an algorithm written by a library vendor takes a 
parameter of type Random.
SplittableRandom is not a Random.  I'm guessing this is because it is not 
thread-safe like the Random
contract promises.

We were hoping to have a single sequence shared between the library that takes 
Random and our
own code that hopes to generate bounded longs.  We want such tight control 
because we are writing
a repeatable tester and want to use the seed to be able to replay sequences 
that cause our
system to fail.

We are looking into somehow retrofitting our code to use SplittableRandom but 
it's likely less
complex for us to just implement the naïve re-roll algorithm [ while(sample >= 
bound) sample = nextLong(); ]

I don't think this will turn into a total blocker for us, you're correct -- 
we'll find a path forward.
But I do think it highlights missing functionality, and the SO post highlights 
that this is a problem 'in the wild'.
It feels like an obvious omission!

Reply via email to