Code example for AtomicReference

Methods: getgetAndSet

0
		this.head = new AtomicReference<Entry<T>>(null);
	} 
 
	@Override 
	public void push(final T element) {
		this.head.getAndSet(new Entry<T>(element, this.head.get()));
	} 
 
	@Override 
	public T pop() { 
		return this.head.getAndSet(this.head.get().getNext()).getValue();
	} 
 
	@Override 
	public T peek() { 
		T result = null;
		if (null != this.head.get()) {
			result = this.head.get().getValue();
		} 
		return result;
Experience pair programming with AI  Get Codota for Java