The Art of Multiprocessor Programming

The Stack
Fig. 11.1 shows a concurrent LockFreeStack class, whose code appears in Figs. 11.2, 11.3 and 11.4. The lock-free stack is a linked list, where the top field points to the first node (or null if the stack is empty.) For simplicity, we usually assume it is illegal to add a null value to a stack.
1 <b class="bold">public class</b> LockFreeStack{ 2 AtomicReference top = ...