AtomicInteger atomicInteger =new AtomicInteger(1);
/**
* atomicInteger的值与expect相比较,如果不相等,则返回false,
* atomicInteger原有值保持不变;如果两者相等,则返回true,atomicInteger的值更新为newValue
*
*
*/
int expect = 2;
int update = 3;
boolean ba = atomicInteger.compareAndSet(expect,update);
网友评论