equal
deleted
inserted
replaced
47 import java.util.stream.DoubleStream; |
47 import java.util.stream.DoubleStream; |
48 import java.util.stream.IntStream; |
48 import java.util.stream.IntStream; |
49 import java.util.stream.LongStream; |
49 import java.util.stream.LongStream; |
50 import java.util.stream.StreamSupport; |
50 import java.util.stream.StreamSupport; |
51 import jdk.internal.misc.Unsafe; |
51 import jdk.internal.misc.Unsafe; |
|
52 import jdk.internal.misc.VM; |
52 |
53 |
53 /** |
54 /** |
54 * A random number generator isolated to the current thread. Like the |
55 * A random number generator isolated to the current thread. Like the |
55 * global {@link java.util.Random} generator used by the {@link |
56 * global {@link java.util.Random} generator used by the {@link |
56 * java.lang.Math} class, a {@code ThreadLocalRandom} is initialized |
57 * java.lang.Math} class, a {@code ThreadLocalRandom} is initialized |
1091 = new AtomicLong(mix64(System.currentTimeMillis()) ^ |
1092 = new AtomicLong(mix64(System.currentTimeMillis()) ^ |
1092 mix64(System.nanoTime())); |
1093 mix64(System.nanoTime())); |
1093 |
1094 |
1094 // at end of <clinit> to survive static initialization circularity |
1095 // at end of <clinit> to survive static initialization circularity |
1095 static { |
1096 static { |
1096 if (java.security.AccessController.doPrivileged( |
1097 String sec = VM.getSavedProperty("java.util.secureRandomSeed"); |
1097 new java.security.PrivilegedAction<>() { |
1098 if (Boolean.parseBoolean(sec)) { |
1098 public Boolean run() { |
|
1099 return Boolean.getBoolean("java.util.secureRandomSeed"); |
|
1100 }})) { |
|
1101 byte[] seedBytes = java.security.SecureRandom.getSeed(8); |
1099 byte[] seedBytes = java.security.SecureRandom.getSeed(8); |
1102 long s = (long)seedBytes[0] & 0xffL; |
1100 long s = (long)seedBytes[0] & 0xffL; |
1103 for (int i = 1; i < 8; ++i) |
1101 for (int i = 1; i < 8; ++i) |
1104 s = (s << 8) | ((long)seedBytes[i] & 0xffL); |
1102 s = (s << 8) | ((long)seedBytes[i] & 0xffL); |
1105 seeder.set(s); |
1103 seeder.set(s); |