Admiring and Understanding LinkedBlockingQueue take Method

Admiring and Understanding LinkedBlockingQueue take Method


In order to admire the code of the implementation of the BlockingQueue, lets have a look at the LinkedBlockingQueue take method. Lets go through the code line by line, understanding the role of each line of code. Line 4: final AtomicInteger count = this. count; In case you already know, AtomicInteger is used for atomic modifications to integers. It offers operations like increment and decrement in a thread safe way. Line 5: final ReentrantLock takeLock = this. takeLock; This lock is used as a monitor for ...