Java Reference
In-Depth Information
ceeds, the insertion is considered to have taken effect; the second CAS (step D ) is considered
“cleanup”, since it can be performed either by the inserting thread or by any other thread. If
D fails, the inserting thread returns anyway rather than retrying the CAS, because no retry is
needed—another thread has already finished the job in its step B ! This works because before
any thread tries to link a new node into the queue, it first checks to see if the queue needs
cleaning up by checking if tail.next is non-null. If it is, it advances the tail pointer first
(perhaps multiple times) until the queue is in the quiescent state.
Search WWH ::




Custom Search