当前位置:网站首页>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边栏推荐
- mysql delete 执行报错:You can‘t specify target table ‘doctor_info‘ for update in FROM clause
- 全新探险者以40万的产品击穿豪华SUV价格壁垒
- 出海季,互联网出海锦囊之本地化
- ModelWhale 云端运行 WRF 中尺度数值气象模式,随时随地即开即用的一体化工作流
- leetcode-693.交替位二进制数
- 使用VS Code搭建ESP-IDF环境
- After the cnpm installation is successful, the prompt is not an internal and external command, nor is it a runnable command solution
- How much does Ark Survival Evolved cost?
- 语音识别新一轮竞争打响,自然对话会是下一个制高点吗?
- Three key expectations for the crypto market in August Price moves north?Still expected to be in turmoil
猜你喜欢

常见分布式理论(CAP、BASE)和一致性协议(Gosssip、Raft)

为教育插上数字化的翅膀,网易云信发布「互联网+教育」整体解决方案

深入浅出Flask PIN

AI也有健忘症?英国41岁教授专访:解决灾难性遗忘

【Unity入门计划】基本概念(8)-瓦片地图 TileMap 01

49 万奖金等你来拿!第四届实时计算 Flink 挑战赛启动,Beyond Stream Processing!

DC-DC 2C (40W/30W) JD6606SX2 power back application

Spark entry learning-2
![[Code Hoof Set Novice Village 600 Questions] Define a function as a macro](/img/7c/7e1469090ca3d1dea703b3fcee7428.png)
[Code Hoof Set Novice Village 600 Questions] Define a function as a macro

Interpretation of the 2021 Cost of Data Breach Report
随机推荐
Leetcode76. Minimal Covering Substring
【码蹄集新手村600题】将一个函数定义宏
5 v 8.4 v1A charging current charging management IC
LyScript 验证PE程序开启的保护
How Navicat connects to MySQL on a remote server
爬虫注意
MATLAB gcf figure save image with black background/transparent background
[Unity Getting Started Plan] Basic Concepts (8) - Tile Map TileMap 01
mysql delete 执行报错:You can‘t specify target table ‘doctor_info‘ for update in FROM clause
高可用版 主数据库数据结构改变 备数据库会自动改变吗
ModelWhale 云端运行 WRF 中尺度数值气象模式,随时随地即开即用的一体化工作流
CS免杀姿势
我写了个”不贪吃蛇“小游戏
使用VS Code搭建ESP-IDF环境
MATLAB gcf图窗保存图像,黑色背景/透明背景
在 360 度绩效评估中应该问的 20 个问题
托尔斯泰:生活中只有两种不幸
ruoyi若依框架@DataScope注解使用以及碰到的一些问题
DC-DC 2C(40W/30W) JD6606SX2退功率应用
leetcode:899. 有序队列【思维题】