Some sun.misc internal APIs are deprectaed in JDK 9 and will be encapsulated or removed in a future release.
/** * A padded cell for distributing counts. Adapted from LongAdder * and Striped64. See their internal docs for explanation. */ @sun.misc.Contended static final class CounterCell { volatile long value; CounterCell(long x) { value = x; } }
/** * A padded cell for distributing counts. Adapted from LongAdder * and Striped64. See their internal docs for explanation. */ @sun.misc.Contended static final class CounterCell { final long value; CounterCell(long x) { value = x; } }
/** * A padded cell for distributing counts. Adapted from LongAdder * and Striped64. See their internal docs for explanation. */ @sun.misc.Contended static final class CounterCell { volatile long value; CounterCell(long x) { value = x; } }
@Contended abstract static class QNode { // in 9, use VarHandle private static final AtomicReferenceFieldUpdater<QNode, QNode> nextUpdater = AtomicReferenceFieldUpdater.newUpdater(QNode.class, QNode.class, "next"); @SuppressWarnings("unused") private volatile QNode next; QNode(final QNode next) { this.next = next; } boolean compareAndSetNext(QNode expect, QNode update) { return nextUpdater.compareAndSet(this, expect, update); } QNode getNext() { return nextUpdater.get(this); } QNode getAndSetNext(final QNode node) { return nextUpdater.getAndSet(this, node); } }
@Contended static final class TaskNode extends QNode { volatile Runnable task; TaskNode(final Runnable task) { // we always start task nodes with a {@code null} next super(null); this.task = task; } Runnable getAndClearTask() { try { return task; } finally { this.task = null; } } }
public class ContentedPoint { @Contended private long x; private long y; public ContentedPoint(long x, long y) { this.x = x; this.y = y; } public long getX() { return x; } public void setX(long x) { this.x = x; } public long getY() { return y; } public void setY(long y) { this.y = y; } }
@Contended static final class TerminateWaiterNode extends QNode { private volatile Thread thread; TerminateWaiterNode(final Thread thread) { // always start with a {@code null} next super(null); this.thread = thread; } Thread getAndClearThread() { // doesn't have to be particularly atomic try { return thread; } finally { thread = null; } } TerminateWaiterNode getNext() { return (TerminateWaiterNode) super.getNext(); } }
@Contended static final class PoolThreadNode extends QNode { private final Thread thread; @SuppressWarnings("unused") private volatile Runnable task; private static final AtomicReferenceFieldUpdater<PoolThreadNode, Runnable> taskUpdater = AtomicReferenceFieldUpdater.newUpdater(PoolThreadNode.class, Runnable.class, "task"); PoolThreadNode(final PoolThreadNode next, final Thread thread) { super(next); this.thread = thread; task = WAITING; } Thread getThread() { return thread; } boolean compareAndSetTask(final Runnable expect, final Runnable update) { return taskUpdater.compareAndSet(this, expect, update); } Runnable getTask() { return taskUpdater.get(this); } PoolThreadNode getNext() { return (PoolThreadNode) super.getNext(); } }
@sun.misc.Contended static final class Cell { volatile long value; Cell(long x) { value = x; }
@sun.misc.Contended static final class Cell { volatile long value; Cell(long x) { value = x; }
@Contended private volatile LogConfigConsumer cfgConsumer;
@Contended class SharedQueueBlockPushBlockPopImpl implements ASharedQueue { long p1, p2, p3, p4, p5, p6, p7;
@Contended class SharedQueueNonBlockingImpl implements ASharedQueue { long p1, p2, p3, p4, p5, p6, p7;
@Contended private long time = 0L; public long time() { @Contended private boolean skipViews = false; public boolean isSkipViews() { @Contended private long systemFlag = 0L; public long systemFlag() { @Contended private long transactionId; public long transactionId() { @Contended private CompletableFuture future; public CompletableFuture future() { @Contended private boolean hasResult; public boolean hasResult() { @Contended private Object commandResult; public Object commandResult() { @Contended
@Contended class LocalQueue { long p1, p2, p3, p4, p5, p6, p7;
@Contended class SharedQueueNonblockPushBlockPopImpl implements ASharedQueue { long p1, p2, p3, p4, p5, p6, p7;
@sun.misc.Contended private static final class BufferedSubscription<T> implements Flow.Subscription, ForkJoinPool.ManagedBlocker {
@Contended class WorkerThread extends Thread { long a1, a2, a3, a4, a5, a6, a7;
@Contended public class AThreadPoolImpl implements AThreadPoolWithAdmin { private static final int MAX_NUM_PRODUCER_AFFINITIES = 10_000;