atomic integer 实现

public final int getAndAddInt(Object o, long offset, int delta) {
        int v;
        do {
            v = getIntVolatile(o, offset);
        } while (!compareAndSwapInt(o, offset, v, v + delta));
        return v;
}

 

posted @ 2017-03-25 17:24  友哥  阅读(153)  评论(0编辑  收藏  举报