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.23 by jsr166, Mon May 19 00:27:06 2008 UTC vs.
Revision 1.28 by jsr166, Mon Sep 27 19:15:15 2010 UTC

# Line 1 | Line 1
1   /*
2 < * Copyright 1995-2007 Sun Microsystems, Inc.  All Rights Reserved.
2 > * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
3   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4   *
5   * This code is free software; you can redistribute it and/or modify it
# Line 18 | Line 18
18   * 2 along with this work; if not, write to the Free Software Foundation,
19   * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20   *
21 < * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 < * CA 95054 USA or visit www.sun.com if you need additional information or
23 < * have any questions.
21 > * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 > * or visit www.oracle.com if you need additional information or have any
23 > * questions.
24   */
25  
26   package java.util;
# Line 32 | Line 32 | import sun.misc.Unsafe;
32   * An instance of this class is used to generate a stream of
33   * pseudorandom numbers. The class uses a 48-bit seed, which is
34   * modified using a linear congruential formula. (See Donald Knuth,
35 < * <i>The Art of Computer Programming, Volume 3</i>, Section 3.2.1.)
35 > * <i>The Art of Computer Programming, Volume 2</i>, Section 3.2.1.)
36   * <p>
37   * If two instances of {@code Random} are created with the same
38   * seed, and the same sequence of method calls is made for each, they
# Line 50 | Line 50 | import sun.misc.Unsafe;
50   * <p>
51   * Many applications will find the method {@link Math#random} simpler to use.
52   *
53 + * <p>Instances of {@code java.util.Random} are threadsafe.
54 + * However, the concurrent use of the same {@code java.util.Random}
55 + * instance across threads may encounter contention and consequent
56 + * poor performance. Consider instead using
57 + * {@link java.util.concurrent.ThreadLocalRandom} in multithreaded
58 + * designs.
59 + *
60 + * <p>Instances of {@code java.util.Random} are not cryptographically
61 + * secure.  Consider instead using {@link java.security.SecureRandom} to
62 + * get a cryptographically secure pseudo-random number generator for use
63 + * by security-sensitive applications.
64 + *
65   * @author  Frank Yellin
66   * @since   1.0
67   */
# Line 65 | Line 77 | class Random implements java.io.Serializ
77       */
78      private final AtomicLong seed;
79  
80 <    private final static long multiplier = 0x5DEECE66DL;
81 <    private final static long addend = 0xBL;
82 <    private final static long mask = (1L << 48) - 1;
80 >    private static final long multiplier = 0x5DEECE66DL;
81 >    private static final long addend = 0xBL;
82 >    private static final long mask = (1L << 48) - 1;
83  
84      /**
85       * Creates a new random number generator. This constructor sets
# Line 256 | Line 268 | class Random implements java.io.Serializ
268       * @return the next pseudorandom, uniformly distributed {@code int}
269       *         value between {@code 0} (inclusive) and {@code n} (exclusive)
270       *         from this random number generator's sequence
271 <     * @exception IllegalArgumentException if n is not positive
271 >     * @throws IllegalArgumentException if n is not positive
272       * @since 1.2
273       */
274  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines