7051516: ThreadLocalRandom seed is never initialized so all instances generate the same sequence
Reviewed-by: chegar, dholmes, mduigou
This commit is contained in:
parent
8bdce645f3
commit
58f7b19611
@ -118,7 +118,13 @@ class Random implements java.io.Serializable {
|
||||
* @see #setSeed(long)
|
||||
*/
|
||||
public Random(long seed) {
|
||||
this.seed = new AtomicLong(initialScramble(seed));
|
||||
if (getClass() == Random.class)
|
||||
this.seed = new AtomicLong(initialScramble(seed));
|
||||
else {
|
||||
// subclass might have overriden setSeed
|
||||
this.seed = new AtomicLong();
|
||||
setSeed(seed);
|
||||
}
|
||||
}
|
||||
|
||||
private static long initialScramble(long seed) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user