当前位置:网站首页>Interview question: talk about your understanding of AQS
Interview question: talk about your understanding of AQS
2022-07-27 22:00:00 【Xiao Zhao, who is working hard for millions of annual salary】
Hello, I'm Qingwei , A delusion 30 Beipiao programmers with an annual salary of millions before the age of .
This column is the common interview questions of big factories that I sorted out , I will give an answer , I hope I can help you
If it helps , Welcome to my other columns :
link : Explore the principles from the source codelink : Java Concurrent programming
link : SQL– Knowledge and principle
In the interview of many big factories , Interviewers have relatively high assessment requirements for concurrent programming , Simply speaking , If you don't understand concurrent programming , Then it's hard for you to pass the interview for a high paying position in a large factory .
Talk to you about AQS The understanding of the
AQS yes AbstractQueuedSynchronizer For short , It is the core component in concurrent programming , It is J.U.C In bag Underlying implementation of multiple components , It can be used to implement multithreaded synchronizer , The underlying implementation of multiple components in the package , Such as Lock、 CountDownLatch、Semaphore And so on AQS.
essentially ,AQS Two locking mechanisms are provided , Exclusive lock , And Shared lock .
Exclusive lock , This is when multiple threads compete for the same shared resource , Only one thread is allowed to access this at one time Shared resources , That is, only one thread in multiple threads can obtain lock resources , such as Lock Medium ReentrantLock The implementation of reentry lock uses AQS Exclusive lock function in .
Shared locks are also called read locks , That is to allow multiple threads to obtain lock resources at the same time , such as CountDownLatch and Semaphore It's all about using AQS Shared lock function in .
AQS In the maintenance of a state Field , Represents lock preemption . And to provide for state Of cas operation . And the method of providing a locked template , such as tryAcquire, You can reproduce and implement the relevant logic .
meanwhile , Threads that cannot be grabbed need to queue and wait , therefore AQS There is a thread waiting in the queue . The most important thing in it is a two-way linked list . The data structure of the node is node,node Store thread information , as well as node The state of . At the same time, it provides relevant operation methods for two-way lists .
If the thread fails to preempt the lock , Will enter AQS Waiting queue in , also park.
At the same time, it provides relevant methods for releasing locks , Releasing the lock will wake up the related thread . Lock preemption .
边栏推荐
- Read Plato farm's eplato and the reason for its high premium
- 2021-11-05类变量和类方法的理解
- day 1 - day 4
- Encapsulate an array into a class
- 美国新宣布制裁的6家中国企业到底是何方神圣?
- Mysql 数据恢复流程 基于binlog redolog undolog
- QT take out the input box string, lineedit
- Is it safe to open an account online now? Then choose which securities to open a securities account
- 软件测试面试题:通过画因果图来写测试用例的步骤为___、___、___、___及把因果图转换为状态图共五个步骤。 利用因果图生成测试用例的基本步骤是?
- 软件测试面试题:在windows下保存一个文本文件时会弹出保存对话框,如果为文件名建立测试用例,等价类应该怎样划分?
猜你喜欢

一篇文章带你走进pycharm的世界----别再问我pycharm的安装和环境配置了!!!

Pytoch distributed training

项目分析(从技术到项目、产品)

一口气学完 Redis 集群方案

Pythia: Facebook's latest open source visual and language multitasking learning framework

What is eplato cast by Plato farm on elephant swap? Why is there a high premium?

Exception -exception

IDEA常用快捷键及设置方法

day 1 - day 4

LInkedList底层源码
随机推荐
Understanding of L1 regularization and L2 regularization [easy to understand]
[day_4-review, basic concepts of objects and arrays - 1]
Software testing interview question: when does the software testing project start? Why?
CocoaPods 重装
看起来是线程池的BUG,但是我认为是源码设计不合理。
哈希表的查找与插入及删除
QT take out the input box string, lineedit
University of Tilburg, Federal University of the Netherlands | neural data to text generation based on small datasets: comparing the added value of two semi supervised learning approvals on top of a l
IDEA连接MySQL数据库并执行SQL查询操作
自研5G芯片商用推迟?未来4年苹果iPhone都将采用高通5G芯片
B站崩了,那晚负责修复的开发人员做了什么?
Up to 7.5gbps! The world's first 5nm 5g baseband snapdragon X60 release: support the aggregation of all major bands!
day 1 - day 4
@Component可以和@Bean 用在同一个类上吗?
Log4j 漏洞仍普遍存在,并持续造成影响
Software test interview question: when saving a text file under windows, a save dialog box will pop up. If a test case is established for the file name, how should equivalent classes be divided?
Why use MQ message oriented middleware? These questions must be solved
Commercial delay of self-developed 5g chip? Apple iPhone will adopt Qualcomm 5g chip in the next four years
对象在内存中存在形式&内存分配机制
项目分析(哪些是it培训给不了)
