当前位置:网站首页>[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 .
边栏推荐
- 梯度下降法求解BP神经网络的简单Demo
- 【Rust 笔记】09-特型与泛型
- 2021-10-19
- Transmit pictures with Base64 encoding
- Un système de gestion de centre commercial pour la conception de cours de technologie d'application de base de données
- Unity interactive water ripple post-treatment
- Unity editor expansion - window, sub window, menu, right-click menu (context menu)
- Solution détaillée de toutes les formules de fonction de transfert (fonction d'activation) du réseau neuronal MATLAB
- 【Rust 笔记】13-迭代器(上)
- Golang 中string和int类型相互转换
猜你喜欢

UE4 source code reading_ Mobile synchronization

Student educational administration management system of C # curriculum design

Base64编码简介

Abstract classes and interfaces

Introduction to Base64 coding
![[updating] wechat applet learning notes_ three](/img/05/958b8d62d3a42b38ca1a2d8631a7f8.png)
[updating] wechat applet learning notes_ three

Constraintlayout's constraintset dynamically modifies constraints

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

Redis的数据结构

OpenGL learning notes
随机推荐
matlab神經網絡所有傳遞函數(激活函數)公式詳解
Ue5 opencv plug-in use
基于SSM的校园失物招领平台,源码,数据库脚本,项目导入运行视频教程,论文撰写教程
Kunlunbase meetup is waiting for you!
[set theory] order relation (the relation between elements of partial order set | comparable | strictly less than | covering | Haas diagram)
Scite change background color
Thymeleaf 404 reports an error: there was unexpected error (type=not found, status=404)
UE4 source code reading_ Bone model and animation system_ Animation compression
Delete the last character of the string in golang
Explain sizeof, strlen, pointer, array and other combination questions in detail
Unity multi open script
Initial unity
Redis cluster series 4
redis集群系列四
Mysql容器化(1)Docker安装MySQL
简易入手《SOM神经网络》的本质与原理
Jupyter remote server configuration and server startup
Golang中删除字符串的最后一个字符
Golang json格式和结构体相互转换
【Rust 笔记】07-结构体