Home » concurrent-sources » EDU.oswego.cs.dl.util.concurrent » [javadoc | source]
public class: SynchronizedRef [javadoc | source]

All Implemented Interfaces:

Direct Known Subclasses:

A simple class maintaining a single reference variable that is always accessed and updated under synchronization.

[ Introduction to this package. ]
Field Summary
protected  Object value_    The maintained reference 
Fields inherited from EDU.oswego.cs.dl.util.concurrent.SynchronizedVariable:
 public SynchronizedRef(Object initialValue) 
    Create a SynchronizedRef initially holding the given reference and using its own internal lock.
 public SynchronizedRef(Object initialValue,
    Object lock) 
    Make a new SynchronizedRef with the given initial value, and using the supplied lock. *
Method from EDU.oswego.cs.dl.util.concurrent.SynchronizedRef Summary:
commit,   get,   set,   swap
Methods from EDU.oswego.cs.dl.util.concurrent.SynchronizedVariable:
execute,   getLock
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from EDU.oswego.cs.dl.util.concurrent.SynchronizedRef Detail:
 public boolean commit(Object assumedValue,
    Object newValue) 
    Set value to newValue only if it is currently assumedValue.
 public final Object get() 
    Return the current value
 public Object set(Object newValue) 
    Set to newValue.
 public Object swap(SynchronizedRef other) 
    Atomically swap values with another SynchronizedRef. Uses identityHashCode to avoid deadlock when two SynchronizedRefs attempt to simultaneously swap with each other. (Note: Ordering via identyHashCode is not strictly guaranteed by the language specification to return unique, orderable values, but in practice JVMs rely on them being unique.)