--- jsr166/src/jsr166e/extra/AtomicDouble.java 2011/10/20 17:47:36 1.10 +++ jsr166/src/jsr166e/extra/AtomicDouble.java 2011/10/25 19:21:27 1.11 @@ -40,7 +40,7 @@ import static java.lang.Double.longBitsT public class AtomicDouble extends Number implements java.io.Serializable { private static final long serialVersionUID = -8405198993435143622L; - private volatile long value; + private volatile transient long value; /** * Creates a new {@code AtomicDouble} with the given initial value. @@ -210,6 +210,28 @@ public class AtomicDouble extends Number return get(); } + /** + * Saves the state to a stream (that is, serializes it). + * + * @serialData The current value is emitted (a {@code double}). + */ + private void writeObject(java.io.ObjectOutputStream s) + throws java.io.IOException{ + s.defaultWriteObject(); + + s.writeDouble(get()); + } + + /** + * Reconstitutes the instance from a stream (that is, deserializes it). + */ + private void readObject(java.io.ObjectInputStream s) + throws java.io.IOException, ClassNotFoundException { + s.defaultReadObject(); + + set(s.readDouble()); + } + // Unsafe mechanics private static final sun.misc.Unsafe unsafe = getUnsafe(); private static final long valueOffset;