You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
publicvoidput(Ee) throwsInterruptedException {
if (e == null) thrownewNullPointerException();
finalintc;
finalNode<E> node = newNode<E>(e);
finalReentrantLockputLock = this.putLock;
finalAtomicIntegercount = this.count;
putLock.lockInterruptibly();
try {
/* * Note that count is used in wait guard even though it is * not protected by lock. This works because count can * only decrease at this point (all other puts are shut * out by lock), and we (or some other waiting put) are * signalled if it ever changes from capacity. Similarly * for all other uses of count in other wait guards. */while (count.get() == capacity) {
notFull.await();
}
enqueue(node);
c = count.getAndIncrement();
if (c + 1 < capacity)
notFull.signal();
} finally {
putLock.unlock();
}
if (c == 0)
signalNotEmpty();
}
publicEtake() throwsInterruptedException {
finalEx;
finalintc;
finalAtomicIntegercount = this.count;
finalReentrantLocktakeLock = this.takeLock;
takeLock.lockInterruptibly();
try {
while (count.get() == 0) {
notEmpty.await();
}
x = dequeue();
c = count.getAndDecrement();
if (c > 1)
notEmpty.signal();
} finally {
takeLock.unlock();
}
if (c == capacity)
signalNotFull();
returnx;
}
LABEL 쓰는 꿀팁~
The text was updated successfully, but these errors were encountered: