Comments (1)
第一个问题
compareAndSetTail代码如下:
private final boolean compareAndSetTail(Node expect, Node update) { return unsafe.compareAndSwapObject(this, tailOffset, expect, update); }
tailOffset就是tail域在AQS对象里的偏移量,用CAS更新尾结点。第一个不用猜测,点进去看看就知道了
第二个问题
从设计上我实在讲不出什么,只能说返回tail没什么意义,可以从以下几点理解
- enq(node)可以简单地理解为插入吧?CAS操作成功后,node即tail,你传了一个node,返回一个一样的node有什么意义呢?
- 看transferForSignal(node),它的作用是唤醒node结点,根据AQS的规定,需要将前一个结点,即node.prev设置成SIGNAL状态。这部分看Condition部分
:) 我也是最近才开始看并发的内容,感觉能有人一起讨论问题还是挺好的,你可以加我QQ:624684849 ,一起讨论问题
from java-concurrency.
Related Issues (19)
- 关于《彻底理解volatile》中示例代码的问题 HOT 4
- 07.三大性质总结:原子性、可见性以及有序性 HOT 1
- 02 节里的图片不显示 HOT 2
- 文中源碼是java 哪個版本?
- Exchanger 代碼有問題
- 建议创建一个gitbook方便阅读 HOT 2
- CountDownLatchDemo HOT 1
- 内存使用计算问题
- 并发编程的优缺点中几个错别字
- 线程状态转换的错误,WAITING不能直接转变为RUNNABLE
- 彻底理解synchronized章节 3.2 Java对象头 里的图片未显示
- 感觉原子类的分类不太合理,有点乱,如下分类感觉更好 HOT 1
- 最后的例子 HOT 1
- 关于偏向锁升级为轻量级锁的疑问
- 图挂了
- 图片不显示格式问题 HOT 1
- 4.彻底理解synchronized HOT 3
- 3.java内存模型以及happens-before规则
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from java-concurrency.