Giter Club home page Giter Club logo

Comments (1)

CoDeleven avatar CoDeleven commented on May 23, 2024

第一个问题

compareAndSetTail代码如下:
private final boolean compareAndSetTail(Node expect, Node update) { return unsafe.compareAndSwapObject(this, tailOffset, expect, update); }
tailOffset就是tail域在AQS对象里的偏移量,用CAS更新尾结点。第一个不用猜测,点进去看看就知道了

第二个问题

从设计上我实在讲不出什么,只能说返回tail没什么意义,可以从以下几点理解

  1. enq(node)可以简单地理解为插入吧?CAS操作成功后,node即tail,你传了一个node,返回一个一样的node有什么意义呢?
  2. 看transferForSignal(node),它的作用是唤醒node结点,根据AQS的规定,需要将前一个结点,即node.prev设置成SIGNAL状态。这部分看Condition部分

:) 我也是最近才开始看并发的内容,感觉能有人一起讨论问题还是挺好的,你可以加我QQ:624684849 ,一起讨论问题

from java-concurrency.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.