// java.util.concurrent.atomic.atomicinteger public final int getandincrement() { return unsafe.getandaddint(this, valueoffset, 1); }
public final int getanddecrement() { return unsafe.getandaddint(this, valueoffset, -1); }
1 2 3 4 5 6 7 8 9 10 11 12
// sun.misc.unsafe 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; }
public native int getintvolatile(object o, long offset);
public final native boolean compareandswapint(object o, long offset, int expected, int x);