1 |
|
/* |
2 |
< |
* @(#)Random.java 1.46 05/11/30 |
2 |
> |
* %W% %E% |
3 |
|
* |
4 |
< |
* Copyright 2006 Sun Microsystems, Inc. All rights reserved. |
4 |
> |
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. |
5 |
|
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. |
6 |
|
*/ |
7 |
|
|
33 |
|
* Many applications will find the method {@link Math#random} simpler to use. |
34 |
|
* |
35 |
|
* @author Frank Yellin |
36 |
< |
* @version 1.46, 11/30/05 |
36 |
> |
* @version %I%, %G% |
37 |
|
* @since 1.0 |
38 |
|
*/ |
39 |
|
public |
45 |
|
* The internal state associated with this pseudorandom number generator. |
46 |
|
* (The specs for the methods in this class describe the ongoing |
47 |
|
* computation of this value.) |
48 |
– |
* |
49 |
– |
* @serial |
48 |
|
*/ |
49 |
|
private final AtomicLong seed; |
50 |
|
|
463 |
|
/** |
464 |
|
* Serializable fields for Random. |
465 |
|
* |
466 |
< |
* @serialField seed long; |
466 |
> |
* @serialField seed long |
467 |
|
* seed for random computations |
468 |
< |
* @serialField nextNextGaussian double; |
468 |
> |
* @serialField nextNextGaussian double |
469 |
|
* next Gaussian to be returned |
470 |
|
* @serialField haveNextNextGaussian boolean |
471 |
|
* nextNextGaussian is valid |
521 |
|
try { |
522 |
|
seedOffset = unsafe.objectFieldOffset |
523 |
|
(Random.class.getDeclaredField("seed")); |
524 |
< |
} catch (Exception ex) { throw new Error(ex); } |
524 |
> |
} catch (Exception ex) { throw new Error(ex); } |
525 |
|
} |
526 |
|
private void resetSeed(long seedVal) { |
527 |
|
unsafe.putObjectVolatile(this, seedOffset, new AtomicLong(seedVal)); |
528 |
|
} |
531 |
– |
|
529 |
|
} |