在作为 JSR166 的一部分引入的类中,作者使用所谓的填充来填充 Striped64.Cell 类的单值字段。
以下是该课程的摘录:
/**
* Padded variant of AtomicLong supporting only raw accesses plus CAS. The value field is placed
* between pads, hoping that the JVM doesn't reorder them.
* <p/>
* JVM intrinsics note: It would be possible to use a release-only form of CAS here, if it were
* provided.
*/
static final class Cell {
volatile long p0, p1, p2, p3, p4, p5, p6;
volatile long value;
volatile long q0, q1, q2, q3, …Run Code Online (Sandbox Code Playgroud)