Is it possible to provide a Seed to a ThreadLocalRandom?
It looks like it isn't.
/**
 * Throws {@code UnsupportedOperationException}.  Setting seeds in
 * this generator is not supported.
 *
 * @throws UnsupportedOperationException always
 */
public void setSeed(long seed) {
    if (initialized)
        throw new UnsupportedOperationException();
    rnd = (seed ^ multiplier) & mask;
}
So can we use ThreadLocalRandom using seed or it's not designed for that?
As @Marko Topolnik commented, ThreadLocalRandom does not allow to set your own seed.
You can bypass this problem by using a ThreadLocal<Random>, as discussed in this question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With