java.util.concurrent.atomic包中对CAS的实现是通过synchronized关键字实现的:
public final synchronized boolean compareAndSet(long expect, long update) { if (value == expect) { value = update; return true; } else { return false; } }