2 * Written by Doug Lea with assistance from members of JCP JSR-166
3 * Expert Group and released to the public domain, as explained at
4 * http://creativecommons.org/licenses/publicdomain
7 package java.util.concurrent.locks;
10 * A synchronizer that may be exclusively owned by a thread. This
11 * class provides a basis for creating locks and related synchronizers
12 * that may entail a notion of ownership. The
13 * <tt>AbstractOwnableSynchronizer</tt> class itself does not manage or
14 * use this information. However, subclasses and tools may use
15 * appropriately maintained values to help control and monitor access
16 * and provide diagnostics.
21 public abstract class AbstractOwnableSynchronizer
22 implements java.io.Serializable {
24 /** Use serial ID even though all fields transient. */
25 private static final long serialVersionUID = 3737899427754241961L;
28 * Empty constructor for use by subclasses.
30 protected AbstractOwnableSynchronizer() { }
33 * The current owner of exclusive mode synchronization.
35 private transient Thread exclusiveOwnerThread;
38 * Sets the thread that currently owns exclusive access. A
39 * <tt>null</tt> argument indicates that no thread owns access.
40 * This method does not otherwise impose any synchronization or
41 * <tt>volatile</tt> field accesses.
43 protected final void setExclusiveOwnerThread(Thread t) {
44 exclusiveOwnerThread = t;
48 * Returns the thread last set by
49 * <tt>setExclusiveOwnerThread</tt>, or <tt>null</tt> if never
50 * set. This method does not otherwise impose any synchronization
51 * or <tt>volatile</tt> field accesses.
52 * @return the owner thread
54 protected final Thread getExclusiveOwnerThread() {
55 return exclusiveOwnerThread;