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

Comparing jsr166/src/main/java/util/concurrent/ThreadLocalRandom.java (file contents):
Revision 1.13 by jsr166, Fri Feb 22 13:47:07 2013 UTC vs.
Revision 1.14 by jsr166, Mon Feb 25 22:26:49 2013 UTC

# Line 343 | Line 343 | public class ThreadLocalRandom extends R
343      private static final long serialVersionUID = -5851777807851030925L;
344  
345      /**
346 +     * @serialField rnd long
347 +     *              seed for random computations
348 +     * @serialField initialized boolean
349 +     *              always true
350 +     */
351 +    private static final ObjectStreamField[] serialPersistentFields = {
352 +            new ObjectStreamField("rnd", long.class),
353 +            new ObjectStreamField("initialized", boolean.class),
354 +    };
355 +
356 +    /**
357 +     * Saves the {@code ThreadLocalRandom} to a stream (that is, serializes it).
358 +     */
359 +    private void writeObject(java.io.ObjectOutputStream out)
360 +        throws java.io.IOException {
361 +
362 +        java.io.ObjectOutputStream.PutField fields = out.putFields();
363 +        fields.put("rnd", UNSAFE.getLong(Thread.currentThread(), SEED));
364 +        fields.put("initialized", true);
365 +        out.writeFields();
366 +    }
367 +
368 +    /**
369       * Returns the {@link #current() current} thread's {@code ThreadLocalRandom}.
370       */
371      private Object readResolve() {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines