`
liuzhaomin
  • 浏览: 207335 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

AbstractOwnableSynchronizer

阅读更多

 

/**A synchronizer that may be exclusively owned by a thread.  This
 * class provides a basis for creating locks and related synchronizers
 * that may entail a notion of ownership.  The
 * AbstractOwnableSynchronizer class itself does not manage or
 * use this information. However, subclasses and tools may use
 * appropriately maintained values to help control and monitor access
 * and provide diagnostics.
*/
public abstract class AbstractOwnableSynchronizer
    implements java.io.Serializable {

    /** Use serial ID even though all fields transient. */
    private static final long serialVersionUID = 3737899427754241961L;

    /**
     * Empty constructor for use by subclasses.
     */
    protected AbstractOwnableSynchronizer() { }

    /**
     * The current owner of exclusive mode synchronization.
     */
    private transient Thread exclusiveOwnerThread;

    /**
     * Sets the thread that currently owns exclusive access. A
     * null argument indicates that no thread owns access.
     * This method does not otherwise impose any synchronization or
     * volatile field accesses.
     */
    protected final void setExclusiveOwnerThread(Thread t) {
        exclusiveOwnerThread = t;
    }

    /**
     * Returns the thread last set by
     * setExclusiveOwnerThread, or null if never
     * set.  This method does not otherwise impose any synchronization
     * or volatile field accesses.
     * @return the owner thread
     */
    protected final Thread getExclusiveOwnerThread() {
        return exclusiveOwnerThread;
    }
}

 

 

 

 

 

 

 

 

分享到:
评论

相关推荐

    Java并发之ReentrantLock类源码解析

    ReentrantLock类继承自AbstractOwnableSynchronizer,AbstractOwnableSynchronizer类中定义了一个exclusiveOwnerThread变量,表示当前拥有的线程。ReentrantLock类内部定义了两个实现类:NonfairSync和FairSync。...

    Java concurrency之锁_动力节点Java学院

    Java 5.0引入的JUC包则提供了更丰富的锁机制,比如`Lock`接口、`ReadWriteLock`接口、`LockSupport`、`Condition`以及一些基于`AbstractOwnableSynchronizer`、`AbstractQueuedSynchronizer`、`...

    Java concurrency之锁_动力节点Java学院整理

    - AbstractOwnableSynchronizer/AbstractQueuedSynchronizer/AbstractQueuedLongSynchronizer:AQS是JUC中的核心抽象类,用于构建锁和其他同步组件。它维护了一个整数状态表示锁的状态,并提供了基于链表的线程阻塞...

    java编发编程:JUC综合讲解

    - **AbstractOwnableSynchronizer**:可拥有同步器的抽象类,用于记录当前拥有者的线程。 - **AbstractQueuedSynchronizer**:抽象类,实现了基于FIFO等待队列的同步器,是许多锁的基础。 - **...

    最新AQS资料整理.pdf

    1. **AQS类及其父类**:了解AQS类的基本结构,以及它继承自AbstractOwnableSynchronizer的原因。 2. **主要属性**:深入理解state字段,以及head和tail这两个指针,它们分别指向队列的首节点和尾节点。 3. **关键...

Global site tag (gtag.js) - Google Analytics