简介:
AbstractOwnableSynchronizer主要提供独占式模式下获取临界区访问权限的线程的设置与获取功能并且获取设置方法没有使用任何同步或者volatile关键字的限制
方法:
1 public abstract class AbstractOwnableSynchronizer 2 implements java.io.Serializable { 3 4 /** Use serial ID even though all fields transient. */ 5 private static final long serialVersionUID = 3737899427754241961L; 6 7 /** 8 * Empty constructor for use by subclasses. 9 */ 10 protected AbstractOwnableSynchronizer() { } 11 12 /** 13 * The current owner of exclusive mode synchronization. 14 */ 15 private transient Thread exclusiveOwnerThread; 16 17 /** 18 * Sets the thread that currently owns exclusive access. 19 * A {@code null} argument indicates that no thread owns access. 20 * This method does not otherwise impose any synchronization or 21 * {@code volatile} field accesses. 22 * @param thread the owner thread 23 */ 24 protected final void setExclusiveOwnerThread(Thread thread) { 25 exclusiveOwnerThread = thread; 设置获取独占式资源访问权限的线程 26 } 27 28 /** 29 * Returns the thread last set by {@code setExclusiveOwnerThread}, 30 * or {@code null} if never set. This method does not otherwise 31 * impose any synchronization or {@code volatile} field accesses. 32 * @return the owner thread 33 */ 34 protected final Thread getExclusiveOwnerThread() { 35 return exclusiveOwnerThread; 获取当前获取独占式资源访问权限的线程 36 } 37 }