< prev index next >

src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java

Print this page
rev 60127 : 8249205: Remove unnecessary trademark symbols


 115  * {@link Lock} implementations, StampedLocks have no notion of ownership.
 116  * Locks acquired in one thread can be released or converted in another.
 117  *
 118  * <p>The scheduling policy of StampedLock does not consistently
 119  * prefer readers over writers or vice versa.  All "try" methods are
 120  * best-effort and do not necessarily conform to any scheduling or
 121  * fairness policy. A zero return from any "try" method for acquiring
 122  * or converting locks does not carry any information about the state
 123  * of the lock; a subsequent invocation may succeed.
 124  *
 125  * <p>Because it supports coordinated usage across multiple lock
 126  * modes, this class does not directly implement the {@link Lock} or
 127  * {@link ReadWriteLock} interfaces. However, a StampedLock may be
 128  * viewed {@link #asReadLock()}, {@link #asWriteLock()}, or {@link
 129  * #asReadWriteLock()} in applications requiring only the associated
 130  * set of functionality.
 131  *
 132  * <p><b>Memory Synchronization.</b> Methods with the effect of
 133  * successfully locking in any mode have the same memory
 134  * synchronization effects as a <em>Lock</em> action, as described in
 135  * Chapter 17 of <cite>The Java&trade; Language Specification</cite>.
 136  * Methods successfully unlocking in write mode have the same memory
 137  * synchronization effects as an <em>Unlock</em> action.  In optimistic
 138  * read usages, actions prior to the most recent write mode unlock action
 139  * are guaranteed to happen-before those following a tryOptimisticRead
 140  * only if a later validate returns true; otherwise there is no guarantee
 141  * that the reads between tryOptimisticRead and validate obtain a
 142  * consistent snapshot.
 143  *
 144  * <p><b>Sample Usage.</b> The following illustrates some usage idioms
 145  * in a class that maintains simple two-dimensional points. The sample
 146  * code illustrates some try/catch conventions even though they are
 147  * not strictly needed here because no exceptions can occur in their
 148  * bodies.
 149  *
 150  * <pre> {@code
 151  * class Point {
 152  *   private double x, y;
 153  *   private final StampedLock sl = new StampedLock();
 154  *
 155  *   // an exclusively locked method




 115  * {@link Lock} implementations, StampedLocks have no notion of ownership.
 116  * Locks acquired in one thread can be released or converted in another.
 117  *
 118  * <p>The scheduling policy of StampedLock does not consistently
 119  * prefer readers over writers or vice versa.  All "try" methods are
 120  * best-effort and do not necessarily conform to any scheduling or
 121  * fairness policy. A zero return from any "try" method for acquiring
 122  * or converting locks does not carry any information about the state
 123  * of the lock; a subsequent invocation may succeed.
 124  *
 125  * <p>Because it supports coordinated usage across multiple lock
 126  * modes, this class does not directly implement the {@link Lock} or
 127  * {@link ReadWriteLock} interfaces. However, a StampedLock may be
 128  * viewed {@link #asReadLock()}, {@link #asWriteLock()}, or {@link
 129  * #asReadWriteLock()} in applications requiring only the associated
 130  * set of functionality.
 131  *
 132  * <p><b>Memory Synchronization.</b> Methods with the effect of
 133  * successfully locking in any mode have the same memory
 134  * synchronization effects as a <em>Lock</em> action, as described in
 135  * Chapter 17 of <cite>The Java Language Specification</cite>.
 136  * Methods successfully unlocking in write mode have the same memory
 137  * synchronization effects as an <em>Unlock</em> action.  In optimistic
 138  * read usages, actions prior to the most recent write mode unlock action
 139  * are guaranteed to happen-before those following a tryOptimisticRead
 140  * only if a later validate returns true; otherwise there is no guarantee
 141  * that the reads between tryOptimisticRead and validate obtain a
 142  * consistent snapshot.
 143  *
 144  * <p><b>Sample Usage.</b> The following illustrates some usage idioms
 145  * in a class that maintains simple two-dimensional points. The sample
 146  * code illustrates some try/catch conventions even though they are
 147  * not strictly needed here because no exceptions can occur in their
 148  * bodies.
 149  *
 150  * <pre> {@code
 151  * class Point {
 152  *   private double x, y;
 153  *   private final StampedLock sl = new StampedLock();
 154  *
 155  *   // an exclusively locked method


< prev index next >