On 12/03/2014 12:20 PM, Martin Buchholz wrote:

I don't think such a general purpose utility belongs in
SplittableRandom or ThreadLocalRandom - those are the clients.  Random
is a slightly better fit, but still not great.


Perhaps one of these could be made to be a good fit.
As of now, this new method (systemSeed) would be called at most
twice ever -- during static init of SplittableRandom and
ThreadLocalRandom. Either of these could be reworked to
use a high-quality derived seed from the other as its
initial seed. In which case systemSeed would be called only once.
Of the two choices, housing the code in ThreadLocalRandom
seems logistically a bit easier. Then SplittableRandom could use

 private static final AtomicLong defaultGen =
   new AtomicLong(ThreadLocalRandom.current().nextLong());

(For that matter, java.util.Random could use the same
idea for its initial seed.)

-Doug


Reply via email to