@@ -29,6 +29,8 @@ public final class Random {
2929 private static final float RANDOM_FLOAT_MULTIPLIER = 0x1.0p-24F ;
3030 private static final double RANDOM_DOUBLE_MULTIPLIER = 0x1.0p-53 ;
3131
32+ private static boolean useSimpleStartSeedEntropy ;
33+
3234 private long currentSeed ;
3335
3436 public Random () {
@@ -46,18 +48,25 @@ public long getSeed() {
4648 }
4749
4850 public long setRandomSeed () {
49- System .out .println ("before curr thread" );
5051 Thread currentThread = Thread .currentThread ();
51- System .out .println ("current thread: " + currentThread );
5252 ThreadLocalRandom currentThreadRandom = ThreadLocalRandom .current ();
53- System .out .println (currentThreadRandom );
5453
55- long l1 = System .nanoTime ();
56- @ SuppressWarnings ("deprecation" )
57- long l2 = currentThread .getId () * START_SEED_THREAD_ID_MULTIPLIER ;
58- long l3 = currentThreadRandom .nextLong ();
54+ long startSeed ;
55+
56+ if (useSimpleStartSeedEntropy ) {
57+
58+ startSeed = System .nanoTime ();
59+
60+ } else {
61+
62+ long l1 = System .nanoTime ();
63+ @ SuppressWarnings ("deprecation" )
64+ long l2 = currentThread .getId () * START_SEED_THREAD_ID_MULTIPLIER ;
65+ long l3 = currentThreadRandom .nextLong ();
66+
67+ startSeed = l1 ^ l2 ^ l3 ;
68+ }
5969
60- long startSeed = l1 ^ l2 ^ l3 ;
6170 setSeed (startSeed );
6271
6372 return startSeed ;
@@ -144,4 +153,8 @@ private static long scrambleSeed(long seed) {
144153 return seed ;
145154 }
146155
156+ public static void setUseSimpleStartSeedEntropy () {
157+ useSimpleStartSeedEntropy = true ;
158+ }
159+
147160}
0 commit comments