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.21 by jsr166, Sun May 18 23:47:56 2008 UTC vs.
Revision 1.25 by jsr166, Wed Aug 5 01:34:23 2009 UTC

# Line 1 | Line 1
1   /*
2 < * Copyright 1995-2007 Sun Microsystems, Inc.  All Rights Reserved.
2 > * Copyright 1995-2008 Sun Microsystems, Inc.  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 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
54 * @version %I%, %G%
66   * @since   1.0
67   */
68   public
# Line 505 | Line 516 | class Random implements java.io.Serializ
516  
517          // The seed is read in as {@code long} for
518          // historical reasons, but it is converted to an AtomicLong.
519 <        long seedVal = (long) fields.get("seed", -1L);
519 >        long seedVal = fields.get("seed", -1L);
520          if (seedVal < 0)
521            throw new java.io.StreamCorruptedException(
522                                "Random: invalid seed");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines