关于Java自增操作的原子性
最近在工作中和一个同事因为自增是不是原子性操作争论的面红耳赤,那Java的自增操作到底是不是原子性操作呢,答案是否的,即Java的自增操作不是原子性操作。1.首先我们先看看Bruce Eckel是怎么说的: In the JVM an increment is not atomic and involves both a read and a write. (via the latestJava Performance Tuning Newsletter...