当前位置:网站首页>[concurrent programming] synchronization container, concurrent container, blocking queue, double ended queue and work secret
[concurrent programming] synchronization container, concurrent container, blocking queue, double ended queue and work secret
2022-07-03 08:32:00 【keeper42】
1、 Synchronization container
The main representatives are Vector and Hashtable, as well as Collections.synchronizedXxx etc. .
The granularity of the lock is the current object as a whole .
Iterators fail in time , That is to say, it is found to be modified in the process of iteration , Will throw ConcurrentModificationException.
2、 Concurrent container
The main representatives are ConcurrentHashMap、CopyOnWriteArrayList、ConcurrentSkipListMap、ConcurrentSkipListSet
The granularity of locks is decentralized 、 Fine grained , That is, reading and writing use different locks .
Iterators have weak consistency , That is, it can tolerate concurrent modification , Don't throw ConcurrentModificationException.
3、 Blocking queues
The main representatives are LinkedBlockingQueue、ArrayBlockingQueue、PriorityBlockingQueue(Comparable,Comparator)、SynchronousQueue.
Provides blocking put and take Method , And support timed offer and poll Method .
Applicable to producers 、 Consumer model ( Thread pools and work queues -Executor)
It is also a synchronization container
4、 Double ended queue and work secret
The main representatives are ArrayDeque and LinkedBlockingDeque.
significance : Just as blocking queues apply to producer consumer patterns , Double ended queue is also applicable to another mode , That is, work secret . In the producer - In consumer design , All consumers share a work queue , And in working secret , Each consumer has its own double ended queue .
If a consumer has completed all the work in their double ended queue , Then it can secretly get work from the end of the double ended queue of other consumers . Better scalability , This is because worker threads do not compete on a single shared task queue .
Most of the time , They all just access their own double ended queues , Thus greatly reducing the competition . When a worker thread needs to access another queue , It gets work from the end of the queue instead of the head , Therefore, the competition on the queue is further reduced .
边栏推荐
- 数据库应用技术课程设计之商城管理系统
- 单调栈-503. 下一个更大元素 II
- Base64 and base64url
- UE4 source code reading_ Mobile synchronization
- Redis cluster series 4
- What is BFC?
- Data analysis exercises
- Creation and content of mapnode -- osgearth rendering engine series (2)
- Intersectionpicker in osgearth
- Simply start with the essence and principle of SOM neural network
猜你喜欢

梯度下降法求解BP神经网络的简单Demo

Installation of PHP FPM software +openresty cache construction

Flex flexible box layout

GIS实战应用案例100篇(七十八)-多规合一数据库设计及数据入库

Un système de gestion de centre commercial pour la conception de cours de technologie d'application de base de données

UE4 source code reading_ Bone model and animation system_ Animation node

Dealing with duplicate data in Excel with xlwings

了解小程序的笔记 2022/7/3

Get to know unity2 for the first time

Unity editor expansion - controls, layouts
随机推荐
了解小程序的笔记 2022/7/3
Student educational administration management system of C # curriculum design
Visual Studio (VS) shortcut keys
Jupyter remote server configuration and server startup
Go resolve ID card
Unity editor expansion - the framework and context of unity imgui
Cesium service deployment, and import and display local 3dfiles data
Unity learning notes
Exe file running window embedding QT window
C#课程设计之学生教务管理系统
MySQL containerization (1) docker installation MySQL
Transmit pictures with Base64 encoding
2021-10-19
[K & R] Chinese Second Edition personal questions Chapter1
Unity interactive water ripple post-treatment
【Rust 笔记】07-结构体
C#课程设计之员工信息管理系统
About the problem that the editor and the white screen of the login interface cannot be found after the location of unityhub is changed
Un système de gestion de centre commercial pour la conception de cours de technologie d'application de base de données
Why can void * be a general pointer