ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/ThreadLocalRandom.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/ThreadLocalRandom.java (file contents):
Revision 1.21 by dl, Thu Aug 22 23:36:02 2013 UTC vs.
Revision 1.22 by dl, Fri Aug 23 23:02:59 2013 UTC

# Line 44 | Line 44 | import java.util.stream.StreamSupport;
44   *
45   * <p>Instances of {@code ThreadLocalRandom} are not cryptographically
46   * secure.  Consider instead using {@link java.security.SecureRandom}
47 < * in security-sensitive applications. Additionally, instances do not
48 < * use a cryptographically random seed unless the {@linkplain
49 < * System#getProperty system property} {@code
50 < * java.util.secureRandomSeed} is set to {@code true}.
47 > * in security-sensitive applications.
48   *
49   * @since 1.7
50   * @author Doug Lea
# Line 105 | Line 102 | public class ThreadLocalRandom extends R
102      /**
103       * The next seed for default constructors.
104       */
105 <    private static final AtomicLong seeder = new AtomicLong(initialSeed());
106 <
107 <    private static long initialSeed() { // same as SplittableRandom
111 <        try {  // ignore exceptions in accessing/parsing properties
112 <            String pp = System.getProperty
113 <                ("java.util.secureRandomSeed");
114 <            if (pp != null && pp.equalsIgnoreCase("true")) {
115 <                byte[] seedBytes = java.security.SecureRandom.getSeed(8);
116 <                long s = (long)(seedBytes[0]) & 0xffL;
117 <                for (int i = 1; i < 8; ++i)
118 <                    s = (s << 8) | ((long)(seedBytes[i]) & 0xffL);
119 <                return s;
120 <            }
121 <        } catch (Exception ignore) {
122 <        }
123 <        int hh = 0; // hashed host address
124 <        try {
125 <            hh = InetAddress.getLocalHost().hashCode();
126 <        } catch (Exception ignore) {
127 <        }
128 <        return (mix64((((long)hh) << 32) ^ System.currentTimeMillis()) ^
129 <                mix64(System.nanoTime()));
130 <    }
131 <
105 >    private static final AtomicLong seeder =
106 >        new AtomicLong(mix64(System.currentTimeMillis()) ^
107 >                       mix64(System.nanoTime()));
108      /**
109       * The seed increment
110       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines