当前位置:网站首页>Usage scenario of copyonwritearraylist
Usage scenario of copyonwritearraylist
2022-04-23 06:09:00 【commonBean】
1. It is suitable for scenarios with small amount of data , It is not suitable for scenes with large amount of data . Because when writing , Array to be copied , Memory consumption , If there are many contents in the original array , May lead to young gc perhaps full gc
2. It is suitable for reading more and writing less , Not suitable for real-time reading .
CopyOnWriteArrayList It can ensure the thread safety of write operation , It can also ensure the final consistency of the data , But the real-time consistency of data cannot be guaranteed .
CopyOnWriteArrayList In write operation , Used ReentrantLock Lock to ensure thread safety , And replace the original array attribute ; But when reading, read directly array, It may happen when the write operation is replaced array Before and after . This will lead to reading old data , Cause inconsistency .
1、 If the write operation is not completed , Then read the data of the original array directly ;
2、 If the write operation is complete , But the reference has not yet pointed to the new array , So it's also reading the original array data ;
3、 If the write operation is complete , And the reference already points to the new array , So read the data directly from the new array .
版权声明
本文为[commonBean]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220533053149.html
边栏推荐
- Pytorch学习记录(七):处理数据和训练模型的技巧
- Pytorch——数据加载和处理
- Supply chain service terms
- Paper on LDCT image reconstruction: edge enhancement based transformer for medical image denoising
- Example of ticket selling with reentrant lock
- 治疗TensorFlow后遗症——简单例子记录torch.utils.data.dataset.Dataset重写时的图片维度问题
- Pytorch notes - observe dataloader & build lenet with torch to process cifar-10 complete code
- 10.Advance Next Round
- 8. Integer Decomposition
- Optional best practices
猜你喜欢

Kibana search syntax

Pytorch學習記錄(十三):循環神經網絡((Recurrent Neural Network)

Pytorch notes - observe dataloader & build lenet with torch to process cifar-10 complete code

JDBC connection database

深入理解去噪论文——FFDNet和CBDNet中noise level与噪声方差之间的关系探索

lambda expressions

Pytorch学习记录(五):反向传播+基于梯度的优化器(SGD,Adagrad,RMSporp,Adam)

自动控制(韩敏版)

線性代數第一章-行列式

Programming record - picture rotation function SciPy ndimage. Simple use and effect observation of rotate()
随机推荐
Pytorch learning record (IX): convolutional neural network in pytorch
Understanding and use of tp50, tp90 and tp99
Solution record of slow access speed of SMB service in redhat6
Opensips (1) -- detailed process of installing opensips
常用编程记录——parser = argparse.ArgumentParser()
On traversal of binary tree
Pytoch learning record (x): data preprocessing + batch normalization (BN)
Supply chain service terms
Pytorch learning record (7): skills in processing data and training models
ValueError: loaded state dict contains a parameter group that doesn‘t match the size of optimizer‘s
IO multiplexing of 09 redis
Calculation (enter the calculation formula to get the result)
PyTorch入门小笔记——利用简单例子观察前向传播各个层输出的size
9.Life, the Universe, and Everything
Use of multithreaded executors
Pyqy5 learning (III): qlineedit + qtextedit
In depth source code analysis servlet first program
Viewer: introduce MySQL date function
Practical operation - Nacos installation and configuration
PyTorch笔记——实现线性回归完整代码&手动或自动计算梯度代码对比