当前位置:网站首页>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 .
边栏推荐
- 关系型数据库的设计思想,20张图给你看的明明白白
- V2.X 同步异常,无法云端同步的帖子一大堆,同步又卡又慢
- The gratitude and resentment between the four swordsmen and code review: "abandon all chaos" to "prodigal son returns"
- 软件测试面试题:系统测试的策略有多少种?
- Small change project (two versions) with detailed ideas
- @Autowired注解与@Resource注解的区别
- Under the epidemic, the mobile phone supply chain and offline channels are blocked! Sales plummeted and inventory was serious!
- Software testing interview question: when does the software testing project start? Why?
- 深入理解递归的方法调用(含实例迷宫问题、汉诺塔、猴子吃桃、斐波拉契、阶乘))
- Pythia: Facebook's latest open source visual and language multitasking learning framework
猜你喜欢
![[question 23] Sudoku game with rotation | DFS (Beijing Institute of Technology / Beijing Institute of Technology / programming methods and practice / primary school)](/img/75/c207f4f562fd5b547c5b3134113154.jpg)
[question 23] Sudoku game with rotation | DFS (Beijing Institute of Technology / Beijing Institute of Technology / programming methods and practice / primary school)

Log4j 漏洞仍普遍存在?

Log4j 漏洞仍普遍存在,并持续造成影响

LInkedList底层源码

How to customize logging of.Net6.0

Why use MQ message oriented middleware? These questions must be solved
![[question 24] logic closed loop (Beijing Institute of Technology / Beijing University of Technology / programming methods and practice / primary school)](/img/c4/71a9933a3a1fdd14f84a41b640f5b5.jpg)
[question 24] logic closed loop (Beijing Institute of Technology / Beijing University of Technology / programming methods and practice / primary school)
Excalidraw: an easy-to-use online, free "hand drawn" virtual whiteboard tool

@Component可以和@Bean 用在同一个类上吗?

除了「加机器」,其实你的微服务还能这样优化
随机推荐
Technology Management - we must focus on the big and let go of the small
深入理解递归的方法调用(含实例迷宫问题、汉诺塔、猴子吃桃、斐波拉契、阶乘))
Software testing interview question: what is regression testing?
Daily news on July 15, 2022: meta announced the launch of make-a-scene: AI image generation can be controlled based on text and sketches
Unit-- read Excel
[numerical analysis exercise] Jacobi iteration method of third-order matrix
软件测试面试题:通过画因果图来写测试用例的步骤为___、___、___、___及把因果图转换为状态图共五个步骤。 利用因果图生成测试用例的基本步骤是?
二维数组的基本用法
More than 100 lines should be split into functions
2021-11-05 understand main method syntax, code block and final keyword
Recursion / backtracking (Part 1)
Search, insert and delete of hash table
一口气学完 Redis 集群方案
Array expansion, sorting, nested statement application
JVM memory model interview summary
day 1 - day 4
学完4种 Redis 集群方案要多久?我一口气给你说完
哈希表的查找与插入及删除
软件测试面试题:在windows下保存一个文本文件时会弹出保存对话框,如果为文件名建立测试用例,等价类应该怎样划分?
美国新宣布制裁的6家中国企业到底是何方神圣?
