< prev index next >

src/share/classes/java/util/concurrent/ThreadLocalRandom.java

Print this page

        

*** 45,54 **** --- 45,55 ---- import java.util.function.LongConsumer; import java.util.stream.DoubleStream; import java.util.stream.IntStream; import java.util.stream.LongStream; import java.util.stream.StreamSupport; + import sun.misc.VM; /** * A random number generator isolated to the current thread. Like the * global {@link java.util.Random} generator used by the {@link * java.lang.Math} class, a {@code ThreadLocalRandom} is initialized
*** 133,146 **** * The next seed for default constructors. */ private static final AtomicLong seeder = new AtomicLong(initialSeed()); private static long initialSeed() { ! String pp = java.security.AccessController.doPrivileged( ! new sun.security.action.GetPropertyAction( ! "java.util.secureRandomSeed")); ! if (pp != null && pp.equalsIgnoreCase("true")) { byte[] seedBytes = java.security.SecureRandom.getSeed(8); long s = (long)(seedBytes[0]) & 0xffL; for (int i = 1; i < 8; ++i) s = (s << 8) | ((long)(seedBytes[i]) & 0xffL); return s; --- 134,145 ---- * The next seed for default constructors. */ private static final AtomicLong seeder = new AtomicLong(initialSeed()); private static long initialSeed() { ! String sec = VM.getSavedProperty("java.util.secureRandomSeed"); ! if (Boolean.parseBoolean(sec)) { byte[] seedBytes = java.security.SecureRandom.getSeed(8); long s = (long)(seedBytes[0]) & 0xffL; for (int i = 1; i < 8; ++i) s = (s << 8) | ((long)(seedBytes[i]) & 0xffL); return s;
< prev index next >