83

ReentrantLock 实现原理 | crossoverJie's Blog

 6 years ago
source link: https://crossoverjie.top/2018/01/25/ReentrantLock/?
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
使用 `synchronize` 来做同步处理时,锁的获取和释放都是隐式的,实现的原理是通过编译后加上不同的机器指令来实现。而 ReentrantLock 就是一个普通的类,它是基于 AQS(AbstractQueuedSynchronizer)来实现的。是一个重入锁:一个线程获得了锁之后仍然可以反复的加锁,不会出现自己阻塞自己的情况。AQS 是 Java 并发包里实现锁、同步的一个重要

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK