public class PaddedAtomicLong extends AtomicLong
AtomicLong to prevent the FalseSharing problem
The CPU cache line commonly be 64 bytes, here is a sample of cache line after padding:
64 bytes = 8 bytes (object reference) + 6 * 8 bytes (padded long) + 8 bytes (a long value)
| 限定符和类型 | 字段和说明 |
|---|---|
long |
p1
Padded 6 long (48 bytes)
|
long |
p2
Padded 6 long (48 bytes)
|
long |
p3
Padded 6 long (48 bytes)
|
long |
p4
Padded 6 long (48 bytes)
|
long |
p5
Padded 6 long (48 bytes)
|
long |
p6
Padded 6 long (48 bytes)
|
| 构造器和说明 |
|---|
PaddedAtomicLong()
Constructors from
AtomicLong |
PaddedAtomicLong(long initialValue) |
| 限定符和类型 | 方法和说明 |
|---|---|
long |
sumPaddingToPreventOptimization()
To prevent GC optimizations for cleaning unused padded references
|
accumulateAndGet, addAndGet, compareAndSet, decrementAndGet, doubleValue, floatValue, get, getAndAccumulate, getAndAdd, getAndDecrement, getAndIncrement, getAndSet, getAndUpdate, incrementAndGet, intValue, lazySet, longValue, set, toString, updateAndGet, weakCompareAndSetbyteValue, shortValuepublic volatile long p1
public volatile long p2
public volatile long p3
public volatile long p4
public volatile long p5
public volatile long p6
public PaddedAtomicLong()
AtomicLongpublic PaddedAtomicLong(long initialValue)
Copyright © 2020. All rights reserved.