Home > Java, Java Collections > The BLOCKING in BlockQueue

The BLOCKING in BlockQueue

One of the core abilities of any concurrent program is the ability for block for events. java.util.BlockingQueue is a good example of an interface which provides that ability.

Following is an example from an array implementation (java.util.ArrayBlockingQueue):

public E take() throws InterruptedException {
final ReentrantLock lock = this.lock;
try {
try {
while (count == 0)
} catch (InterruptedException ie) {
notEmpty.signal(); // propagate to non-interrupted thread
throw ie;
E x = extract();
return x;
} finally {

Categories: Java, Java Collections
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: