equal
deleted
inserted
replaced
163 * an overriding method may use all 64 bits of the {@code long} |
163 * an overriding method may use all 64 bits of the {@code long} |
164 * argument as a seed value. |
164 * argument as a seed value. |
165 * |
165 * |
166 * @param seed the initial seed |
166 * @param seed the initial seed |
167 */ |
167 */ |
168 synchronized public void setSeed(long seed) { |
168 public synchronized void setSeed(long seed) { |
169 this.seed.set(initialScramble(seed)); |
169 this.seed.set(initialScramble(seed)); |
170 haveNextNextGaussian = false; |
170 haveNextNextGaussian = false; |
171 } |
171 } |
172 |
172 |
173 /** |
173 /** |
578 * @return the next pseudorandom, Gaussian ("normally") distributed |
578 * @return the next pseudorandom, Gaussian ("normally") distributed |
579 * {@code double} value with mean {@code 0.0} and |
579 * {@code double} value with mean {@code 0.0} and |
580 * standard deviation {@code 1.0} from this random number |
580 * standard deviation {@code 1.0} from this random number |
581 * generator's sequence |
581 * generator's sequence |
582 */ |
582 */ |
583 synchronized public double nextGaussian() { |
583 public synchronized double nextGaussian() { |
584 // See Knuth, ACP, Section 3.4.1 Algorithm C. |
584 // See Knuth, ACP, Section 3.4.1 Algorithm C. |
585 if (haveNextNextGaussian) { |
585 if (haveNextNextGaussian) { |
586 haveNextNextGaussian = false; |
586 haveNextNextGaussian = false; |
587 return nextNextGaussian; |
587 return nextNextGaussian; |
588 } else { |
588 } else { |
1195 } |
1195 } |
1196 |
1196 |
1197 /** |
1197 /** |
1198 * Save the {@code Random} instance to a stream. |
1198 * Save the {@code Random} instance to a stream. |
1199 */ |
1199 */ |
1200 synchronized private void writeObject(ObjectOutputStream s) |
1200 private synchronized void writeObject(ObjectOutputStream s) |
1201 throws IOException { |
1201 throws IOException { |
1202 |
1202 |
1203 // set the values of the Serializable fields |
1203 // set the values of the Serializable fields |
1204 ObjectOutputStream.PutField fields = s.putFields(); |
1204 ObjectOutputStream.PutField fields = s.putFields(); |
1205 |
1205 |