Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

面经手册第17篇《ReentrantLock之AQS原理分析和实践使用》中图的问题 #347

Open
JinLS opened this issue Sep 29, 2022 · 0 comments

Comments

@JinLS
Copy link
Contributor

JinLS commented Sep 29, 2022

图17-2 :https://bugstack.cn/assets/images/2020/interview/interview-17-2.png
1、nonfairTryAcquire根据源码应该是一个逻辑分支 final boolean nonfairTryAcquire(int acquires) 返回true和false两种情况,应该是一一个“菱形”选择分支。
2、nonfairTryAcquire其中有个子流程 (如果state=0 则cas修改 设置独占线程并返回true,如果state!=0 则判断是否当前线程重入? 是的话State+1 返回true,其他情况均为false)
3、cas修改共享变量是否成功 并不是 进入current == getExclusiveOwnerThread() 的判断条件,且修改成功后 说明获得了锁 与流程图中不符。

欢迎各位一起交流指导:v信:JinLS1216 周大拿

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant