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

Comparing jsr166/src/jsr166y/ThreadLocalRandom.java (file contents):
Revision 1.7 by jsr166, Thu Jul 23 19:25:45 2009 UTC vs.
Revision 1.8 by jsr166, Thu Jul 23 23:07:57 2009 UTC

# Line 38 | Line 38 | public class ThreadLocalRandom extends R
38      private final static long mask = (1L << 48) - 1;
39  
40      /**
41 <     * The random seed. We can't use super.seed
41 >     * The random seed. We can't use super.seed.
42       */
43      private long rnd;
44  
# Line 77 | Line 77 | public class ThreadLocalRandom extends R
77  
78      /**
79       * Returns the current Thread's ThreadLocalRandom.
80 +     *
81       * @return the current Thread's ThreadLocalRandom
82       */
83      public static ThreadLocalRandom current() {
# Line 86 | Line 87 | public class ThreadLocalRandom extends R
87      /**
88       * Throws UnsupportedOperationException. Setting seeds in this
89       * generator is unsupported.
90 +     *
91       * @throws UnsupportedOperationException always
92       */
93      public void setSeed(long seed) {
# Line 96 | Line 98 | public class ThreadLocalRandom extends R
98      }
99  
100      protected int next(int bits) {
101 <        return (int)((rnd = (rnd * multiplier + addend) & mask) >>> (48-bits));
101 >        rnd = (rnd * multiplier + addend) & mask;
102 >        return (int) (rnd >>> (48-bits));
103      }
104  
105      /**
106       * Returns a pseudorandom, uniformly distributed value between the
107       * given least value (inclusive) and bound (exclusive).
108 +     *
109       * @param least the least value returned
110       * @param bound the upper bound (exclusive)
111       * @throws IllegalArgumentException if least greater than or equal
# Line 116 | Line 120 | public class ThreadLocalRandom extends R
120  
121      /**
122       * Returns a pseudorandom, uniformly distributed value
123 <     * between 0 (inclusive) and the specified value (exclusive)
123 >     * between 0 (inclusive) and the specified value (exclusive).
124 >     *
125       * @param n the bound on the random number to be returned.  Must be
126       *        positive.
127       * @return the next value
# Line 134 | Line 139 | public class ThreadLocalRandom extends R
139          while (n >= Integer.MAX_VALUE) {
140              int bits = next(2);
141              long half = n >>> 1;
142 <            long nextn = ((bits & 2) == 0)? half : n - half;
142 >            long nextn = ((bits & 2) == 0) ? half : n - half;
143              if ((bits & 1) == 0)
144                  offset += n - nextn;
145              n = nextn;
# Line 145 | Line 150 | public class ThreadLocalRandom extends R
150      /**
151       * Returns a pseudorandom, uniformly distributed value between the
152       * given least value (inclusive) and bound (exclusive).
153 +     *
154       * @param least the least value returned
155       * @param bound the upper bound (exclusive)
156       * @return the next value
# Line 159 | Line 165 | public class ThreadLocalRandom extends R
165  
166      /**
167       * Returns a pseudorandom, uniformly distributed {@code double} value
168 <     * between 0 (inclusive) and the specified value (exclusive)
168 >     * between 0 (inclusive) and the specified value (exclusive).
169 >     *
170       * @param n the bound on the random number to be returned.  Must be
171       *        positive.
172       * @return the next value
# Line 174 | Line 181 | public class ThreadLocalRandom extends R
181      /**
182       * Returns a pseudorandom, uniformly distributed value between the
183       * given least value (inclusive) and bound (exclusive).
184 +     *
185       * @param least the least value returned
186       * @param bound the upper bound (exclusive)
187       * @return the next value

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines