7051516: ThreadLocalRandom seed is never initialized so all instances generate the same sequence
Reviewed-by: chegar, dholmes, mduigou
--- a/jdk/src/share/classes/java/util/Random.java Mon Jun 20 17:38:15 2011 +0800
+++ b/jdk/src/share/classes/java/util/Random.java Mon Jun 20 12:27:20 2011 +0100
@@ -118,7 +118,13 @@
* @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) {