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

Comparing jsr166/src/main/java/util/Random.java (file contents):
Revision 1.3 by dl, Mon Aug 25 18:33:04 2003 UTC vs.
Revision 1.4 by jsr166, Fri Nov 7 01:36:42 2003 UTC

# Line 1 | Line 1
1   /*
2 < * @(#)Random.java      1.39 03/01/23
2 > * %W% %E%
3   *
4   * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
5   * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
# Line 33 | Line 33 | import java.util.concurrent.atomic.Atomi
33   * class <code>Math</code> simpler to use.
34   *
35   * @author  Frank Yellin
36 < * @version 1.39, 01/23/03
36 > * @version %I%, %G%
37   * @see     java.lang.Math#random()
38   * @since   JDK1.0
39   */
# Line 55 | Line 55 | class Random implements java.io.Serializ
55      private final static long addend = 0xBL;
56      private final static long mask = (1L << 48) - 1;
57  
58 <    /**
59 <     * Creates a new random number generator. Its seed is initialized to
60 <     * a value based on the current time:
61 <     * <blockquote><pre>
62 <     * public Random() { this(System.currentTimeMillis()); }</pre></blockquote>
63 <     * Two Random objects created within the same millisecond will have
64 <     * the same sequence of random numbers.
65 <     *
66 <     * @see     java.lang.System#currentTimeMillis()
58 >    /**
59 >     * Creates a new random number generator. This constructor sets
60 >     * the seed of the random number generator to a value very likely
61 >     * to be distinct from any other invocation of this constructor.
62       */
63 <    public Random() { this(System.currentTimeMillis()); }
63 >    public Random() { this(++seedUniquifier + System.nanoTime()); }
64 >    private static volatile long seedUniquifier = 8682522807148012L;
65  
66      /**
67       * Creates a new random number generator using a single

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines