title: ConcurrentLinkedQueue Code Explanation
body: <p><a href="http://www.java2s.com/Open-Source/Java-Open-Source-Library/7-JDK/java/java/util/concurrent/ConcurrentLinkedQueue.java.htm" rel="nofollow noreferrer">http://www.java2s.com/Open-Source/Java-Open-Source-Library/7-JDK/java/java/util/concurrent/ConcurrentLinkedQueue.java.htm</a></p>
  
  <p>The above is the source code of ConcurrentLinkedQueue.
  I am not able to understand one condition.</p>
  
  <p>How the condition <strong>(p == q)</strong> will come in the below snippet code from offer method</p>
  
  <pre><code>  public boolean offer(E e) {
          checkNotNull(e);
          final Node&lt;E&gt; newNode = new Node&lt;E&gt;(e);
  
          for (Node&lt;E&gt; t = tail, p = t;;) {
              Node&lt;E&gt; 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 time
                          casTail(t, newNode);  // Failure is OK.
                      return true;
                  }
                  // Lost CAS race to another thread; re-read next
              }
              else if (p == q)
                  // We have fallen off list.  If tail is unchanged, it
                  // will also be off-list, in which case we need to
                  // jump to head, from which all live nodes are always
                  // reachable.  Else the new tail is a better bet.
                  p = (t != (t = tail)) ? t : head;
              else
                  // Check for tail updates after two hops.
                  p = (p != t &amp;&amp; t != (t = tail)) ? t : q;
          }
      }
  </code></pre>
  
  <p>and also what does the author mean by "We have fallen off List"</p>