lundi 3 octobre 2016

ThreadLocalRandom setSeed

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?




Aucun commentaire:

Enregistrer un commentaire