lockfree 算法 多线程下不需要加锁 2016/03/15 17328 [Java]代码 private AtomicInteger temp = new AtomicInteger(); public void set(int value) { for (;;) { int currentValue = temp.get(); if (value != currentValue) { if (temp.compareAndSet(currentValue, value)) { break; } else { continue; } } } }