1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| public Abstract class AbstractQueuedSynchronized{ private static final long STATE; private transient volatile Node head; private transient volatile Node tail; protected boolean tryAcquire(int arg) { throw new UnsupportedOperationException(); } protected boolean tryRelease(int arg) { throw new UnsupportedOperationException(); } protected int tryAcquireShared(int arg) { throw new UnsupportedOperationException(); } final void enqueue(ConditionNode node) { if (node != null) { boolean unpark = false; while(true) { Node t; if ((t = this.tail) == null && (t = this.tryInitializeHead()) == null) { unpark = true; break; } node.setPrevRelaxed(t); if (this.casTail(t, node)) { t.next = node; if (t.status < 0) { unpark = true; } break; } } if (unpark) { LockSupport.unpark(node.waiter); } } } }
|