Code example for AtomicReferenceFieldUpdater

Methods: compareAndSet

0
                 headUpdater =
                 AtomicReferenceFieldUpdater.newUpdater
                 (ConcNodeCachingStack.class, Node.class, "head"); 
     
	private boolean casHead(Node<T> cmp, Node<T> val) {
		return headUpdater.compareAndSet(this, cmp, val);
	} 
	 
	/** 
	 * Second stack of free nodes for reuse. 
	 */ 
    volatile Node<T> freeNode = null;
     
    @SuppressWarnings("rawtypes") 
	private static final 
			    AtomicReferenceFieldUpdater<ConcNodeCachingStack, Node>
			    freeNodeUpdater =
			    AtomicReferenceFieldUpdater.newUpdater
			    (ConcNodeCachingStack.class, Node.class, "freeNode"); 
 
Contextual code suggestions in your IDE  Get Codota for Java