• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
flydoging
博客园    首页    新随笔    联系   管理    订阅  订阅

AbstractOwnableSynchronizer源码

简介:

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 }

 



posted @ 2020-08-26 23:09  flydoging  阅读(264)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3