当前位置:网站首页>CopyOnWriteArrayList details
CopyOnWriteArrayList details
2022-08-03 16:08:00 【jerry_dyy】
Background:
ArrayList is not thread-safe. Although Collections.SynchronizedList is thread-safe, it simply adds a Synchronized synchronization block to all methods, so thatAlthough it can guarantee thread safety, it means that only one thread can operate the list at the same time, and the concurrency efficiency is low.
Collections.SynchronizedList is at best a thread-safe container, not a concurrent container.Therefore, we have today's protagonist: CopyOnWriteArrayList.
CopyOnWriteArrayList specific implementation
CopyOnWriteArrayList is an ArrayList that uses the CopyOnWrite mechanism, which is the copy-on-write mechanism.To put it simply, when reading, it is the same as ordinary ArrayList. When writing, it needs to be locked. In the locked synchronization block, the original array is copied to a new array, and the new array is added or deleted.After the specified value, finally change the pointer of the reference array in CopyOnWriteArrayList.
边栏推荐
猜你喜欢
随机推荐
leetcode: 899. Ordered Queue [Thinking Question]
Awesome!Coroutines are finally here!Thread is about to be in the past
破解数字化转型困局,企业分析协同场景案例解析
[Code Hoof Set Novice Village 600 Questions] Define a function as a macro
技术干货|如何将 Pulsar 数据快速且无缝接入 Apache Doris
posgresql 到 es 报这个错误 ,啥意思
mysql delete 执行报错:You can‘t specify target table ‘doctor_info‘ for update in FROM clause
您的移动端app安全吗
【深度学习】今日bug(8月2)
语音识别新一轮竞争打响,自然对话会是下一个制高点吗?
Small Tools(4) 整合Seata1.5.2分布式事务
基于DMS的数仓智能运维服务,知多少?
Taurus.MVC WebAPI 入门开发教程1:框架下载环境配置与运行(含系列目录)。
字典表(还需要输入2个字)
基于牛顿方法在直流微电网潮流研究(Matlab代码实现)
NodeJs - cross domain
不安装运行时运行.NET程序
"Avnet Embedded Weekly" Issue 276: 2022.07.25--2022.07.31
爬虫注意
如何启动 NFT 集合