5

关于 AQS 里的共享式地获取同步状态 acquireShared 方法,多个线程都可以共享式的获取...

 3 years ago
source link: https://www.v2ex.com/t/786804
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.
neoserver,ios ssh client

V2EX  ›  Java

关于 AQS 里的共享式地获取同步状态 acquireShared 方法,多个线程都可以共享式的获取了,直接不用锁不就好了吗

  0576coder · 1 小时 52 分钟前 · 45 次点击

看到梳理关于 AbstractQueuedSynchronize 里的介绍,看懂了大概一半不到把 似懂非懂

我想不通什么场景下需要共享式,还有比如我有 100 个线程,这种共享式的话 是不是我 100 个线程都能获取到,那不就意义不大了吗

比如我读文件 我就不加锁好了,我只有在写文件的时候再加锁= =

对于共享式还是没理解

我感觉锁都是独占式的


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK