码迷,mamicode.com
首页 > 编程语言 > 详细

Java中的锁机制

时间:2018-10-04 09:10:29      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:sha   zed   hot   ups   queue   arch   time   share   int   

Java中的锁机制:

  1. API层面:Synchronized,AQS(CLH): ReentrantLock,ReentrantReadWriteLock,StampedLock(Ordered RW locks)
  2. JVM层面(Hotspot): SpinLock,Biased,Stack-Locked(轻量级锁), Inflated(重量级锁)
    • Neutral: Unlocked
    • Biased: Locked/Unlocked + Unshared
    • Stack-Locked: Locked + Shared but uncontended,The mark points to displaced mark word on the owner thread‘s stack.
    • Inflated: Locked/Unlocked + Shared and contended,Threads are blocked in monitorenter or wait().,The mark points to heavy-weight "objectmonitor" structure.

参考:
http://openjdk.java.net/groups/hotspot/docs/RuntimeOverview.html
AbstractQueuedLongSynchronizer,StampedLock源码
http://cs.rochester.edu/research/synchronization/pseudocode/ss.html

Java中的锁机制

标签:sha   zed   hot   ups   queue   arch   time   share   int   

原文地址:http://blog.51cto.com/thinklili/2292328

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!