当前位置:网站首页>Detailed explanation of ReentrantReadWriteLock
Detailed explanation of ReentrantReadWriteLock
2022-08-03 16:09:00 【jerry_dyy】
Introduction:
All operations in ReentrantLock are mutually exclusive. In reality, there is a scenario where reading is very frequent, but writing is very little.In such a scenario, if the read and the read are not mutually exclusive, then the concurrency efficiency can be greatly improved, so the corresponding ReentrantLReadWriteLock appears.ReentrantReadWriteLock can do: read-read sharing, read-write mutual exclusion, and write-write mutual exclusion.
The implementation method is: two locks are encapsulated internally, one exclusive lock and one shared lock, between the threads that acquire the exclusive lockTo be synchronized; the threads between acquiring the exclusive lock and acquiring the shared lock are also synchronized; the threads acquiring the shared lock do not need to be synchronized.
Example of use:
public class ReentrantReadWriteLockDemo {private ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock();private ReentrantReadWriteLock.ReadLock readLock = rwLock.readLock();private ReentrantRead
边栏推荐
- 参与便有奖,《新程序员》杂志福利来袭!
- 13、OOM模拟
- [微信小程序开发者工具] × #initialize
- 瞌睡检测系统介绍
- Leetcode76. 最小覆盖子串
- 产品以及研发团队有使用专业的办公软件,如禅道、蓝湖等,他们应该如何使用 Tita 系统?
- [Unity Getting Started Plan] Basic Concepts (8) - Tile Map TileMap 01
- 面了个腾讯35k出来的,他让我见识到什么叫精通MySQL调优
- Optimal Power Flow (OPF) for High Voltage Direct Current (HVDC) (Matlab code implementation)
- QT QT 】 【 to have developed a good program for packaging into a dynamic library
猜你喜欢
I am doing open source in Didi
Small Tools(4) 整合Seata1.5.2分布式事务
A new round of competition for speech recognition has started. Will natural dialogue be the next commanding height?
攻防世界----bug
leetcode: 899. Ordered Queue [Thinking Question]
Small Tools (4) integrated Seata1.5.2 distributed transactions
AI也有健忘症?英国41岁教授专访:解决灾难性遗忘
QT QT 】 【 to have developed a good program for packaging into a dynamic library
扫雷?拿来吧你(递归展开+坐标标记)
How much do you know about the intelligent operation and maintenance service of data warehouse based on DMS?
随机推荐
面了个腾讯35k出来的,他让我见识到什么叫精通MySQL调优
Introduction to spark learning - 1
posgresql 到 es 报这个错误 ,啥意思
GTK实现旋转加载动画
请问大家,MySQL全量怎么样可以提高性能呢?我这里瓶颈是在Source上,在不增加并行度的情况下,
分享一款免费OPC UA服务器
TCP 可靠吗?为什么?
30W 2C(JD6606S + FP6652X2)BOM
如何将二维空间先验注入到ViT中? UMA&港理工&阿里提出SP-ViT,为视觉Transformer学习2D空间先验知识!...
Convex Optimization of Optimal Power Flow (OPF) in Microgrids and DC Grids (Matlab Code Implementation)
Introduction to the advantages of the new generation mesh network protocol T-Mesh wireless communication technology
【899. Ordered Queue】
基于DMS的数仓智能运维服务,知多少?
【Unity入门计划】制作RubyAdventure01-玩家的创建&移动
MySQL性能优化_小表驱动大表
技术干货|如何将 Pulsar 数据快速且无缝接入 Apache Doris
微电网和直流电网中最优潮流(OPF)的凸优化(Matlab代码实现)
使用VS Code搭建ESP-IDF环境
Why do I strongly recommend using smart async?
AWS China SDN Connector