相关疑难解决方法(0)

ConcurrentLinkedQueue代码说明

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

以上是ConcurrentLinkedQueue的源代码.我无法理解一个条件.

条件(p == q)将如何来自offer方法的以下代码段代码

  public boolean offer(E e) {
        checkNotNull(e);
        final Node<E> newNode = new Node<E>(e);

        for (Node<E> t = tail, p = t;;) {
            Node<E> q = p.next;
            if (q == null) {
                // p is last node
                if (p.casNext(null, newNode)) {
                    // Successful CAS is the linearization point
                    // for e to become an element of this queue,
                    // and for newNode to become "live".
                    if (p != t) // hop two nodes at a …
Run Code Online (Sandbox Code Playgroud)

java queue concurrency multithreading

7
推荐指数
1
解决办法
951
查看次数

标签 统计

concurrency ×1

java ×1

multithreading ×1

queue ×1