Starvation in non-blocking approaches
问题 I've been reading about non-blocking approaches for some time. Here is a piece of code for so called lock-free counter. public class CasCounter { private SimulatedCAS value; public int getValue() { return value.get(); } public int increment() { int v; do { v = value.get(); } while (v != value.compareAndSwap(v, v + 1)); return v + 1; } } I was just wondering about this loop: do { v = value.get(); } while (v != value.compareAndSwap(v, v + 1)); People say: So it tries again, and again, until all