Fork me on GitHub

Hi, everyone Are an Atom's swaps in danger of starvation ? (since I looked at the code and didn't find a mechanism to prioritize older swaps or am I wrong?)


We wanted to use atom in a stream-processing (kind-of) application. But we need to make sure that swaps don't get delayed indefinitely.


Under the covers it's just invoking AtomicReference.compareAndSet in a loop, so there is the chance of livelocking a thread if the value of the atom keeps changing between reading the old value and calling CAS.