ConcurrentLinkedQueue Code Explanation

后端 未结 2 426
悲哀的现实
悲哀的现实 2020-12-31 21:18

http://www.java2s.com/Open-Source/Java-Open-Source-Library/7-JDK/java/java/util/concurrent/ConcurrentLinkedQueue.java.htm

The above is the source code of ConcurrentL

2条回答
  •  有刺的猬
    2020-12-31 22:22

    The condition asks the question "Is the current node the same as the next node?"

    If so, you've fallen off list ( documentation in line. )

    The basic outline of steps is:

    1. create a new node for the offered data.
    2. walk the list to find the last node
    3. insert new node as new tail.

    The other parts of the if statement are handling concurrent modification issues.

    To better understand what's going on, read Node.casTail() and the casNext()

提交回复
热议问题