public E poll(){
  for (; ; ) {
    Node<E> h=head;
    Node<E> t=tail;
    Node<E> first=h.getPrev();
    if (h == head) {
      if (h != t) {
        if (first == null) {
          fixList(t,h);
          continue;
        }
        E item=first.getItem();
        if (casHead(h,first)) {
          h.setNext(null);
          h.setPrev(null);
          count.decrementAndGet();
          return item;
        }
      }
 else {
        return null;
      }
    }
  }
}

public E poll ( ) { for ( ; ; ) { Node < E > h = head ; Node < E > t = tail ; Node < E > first = h . getPrev ( ) ; if ( h == head ) { if ( h != t ) { if ( first == null ) { fixList ( t , h ) ; continue ; } E item = first . getItem ( ) ; if ( casHead ( h , first ) ) { h . setNext ( null ) ; h . setPrev ( null ) ; count . decrementAndGet ( ) ; return item ; } } else { return null ; } } } }
dequeues an element from the queue . after a successful cashead , the prev and next pointers of the dequeued node are set to null to allow garbage collection .
