当前位置:网站首页>Source code analysis of linkedblockingqueue
Source code analysis of linkedblockingqueue
2022-07-28 08:38:00 【trigger333】
Catalog
offer Implementation and ArrayBQ almost
and ArrayBQ The difference between
Specific experiments can refer to
BlockingQueue There are a lot of , Here is the main introduction LinkedBQ.

Construction method
The default capacity is integer Maximum

linkedBQ It uses One way linked list

Additive elements
put

offer Implementation and ArrayBQ almost
Blocking queues ArrayBlockingQueue The source code parsing _trigger333 The blog of -CSDN Blog
Pull element
Corresponding to addition
poll Corresponding offer, take Corresponding put.

and ArrayBQ The difference between
LinkedBQ Linked list ,ArrayBQ It's an array , When adding frequently LinkedBQ You need to create a node , and ArrayBQ Just add it directly , When deleting frequently LinkedBQ The node of will point to itself help GC, and ArrayBQ Just put the operation index that will do , So when there are many single operations ,ArrayBQ The performance of adding and deleting is higher , If there are both additions and deletions , that LinkedBQ These two operations do not interfere with each other , and ArrayBQ You can only add or delete .
LinkedBQ There are two locks inside , One is putLock, One is takeLock, There are also two Condition, That is to say put If there are elements in the element , It won't affect take Of , Only when the elements in the linked list are from 0 Turn into 1 I will inform you to wait take Threads . Empathy take It won't affect put.
and ArrayBQ Inside Only one lock lock And two Condition,put Not when take,take Not when put.
therefore LinkedBQ The throughput in multithreaded producer and consumer mode will be greater .
Specific experiments can refer to
边栏推荐
- GBASE亮相联通云巡展(四川站) 以专业赋能云生态
- 单片机IO口控制12V电压通断,MOS和三极管电路
- CarSim simulation quick start (10) - Modeling of braking system
- The five pictures tell you: why is there such a big gap between people in the workplace?
- Can‘t connect to server on ‘IP‘ (60)
- Export SQL server query results to excel table
- 招贤纳士,GBASE高端人才招募进行中
- (十三)基于51单片机的简单温度报警装置
- GBase 8s是否支持存储关系型数据和对象型数据?
- C轮融资已完成!思迈特软件领跑国内BI生态赋能,产品、服务竿头一步
猜你喜欢
随机推荐
Usage of qgroupbox
leetcode/排序数组中两个数字之和
微服务架构 Sentinel 的服务限流及熔断
What happens when you unplug the power? Gaussdb (for redis) dual life keeps you prepared
网口网络水晶头RJ45、POE接口定义线序
Allure use
GBASE亮相联通云巡展(四川站) 以专业赋能云生态
SQL Server查询结果导出到EXCEL表格
CarSim simulation quick start (XI) - Driver Model (1)
Blog Building 9: add search function to Hugo
How to set it to pop up the right-click menu
sql server时间字段排序
Usage of qmap
博客搭建九:hugo添加搜索功能
解决:IndexError: index 13 is out of bounds for dimension 0 with size 13
2021-07-02
leetcode/单词长度的最大乘积
微信小程序----微信小程序浏览pdf文件
Es6: arrow function usage
PostgreSQL:无法更改视图或规则使用的列的类型









