In this section from java.util.concurrent.LinkedBlockingQueue.put() method, I think there is no need of AtomicInteger. Considering there is only one thread inside lock(). Am I correct?
putLock.lockInterruptibly();
try {
while (count.get() == capacity) {
notFull.await();
}
enqueue(node);
c = count.getAndIncrement();
if (c + 1 < capacity)
notFull.signal();
} finally {
putLock.unlock();
}
I checked many questions, but can not find answer. My question: there is only one thread inside lock, so why to use AtomicInteger here