public E getElementBlocking() throws InterruptedException {
		lock.lock();
		try {
			while (open && elements.isEmpty()) {
				nonEmpty.await();
			}

			if (open) {
				return elements.removeFirst();
			} else {
				throw new IllegalStateException("queue is closed");
			}
		} finally {
			lock.unlock();
		}
	}
public E getElementBlocking ( ) throws InterruptedException { lock . lock ( ) ; try { while ( open && elements . isEmpty ( ) ) { nonEmpty . await ( ) ; } if ( open ) { return elements . removeFirst ( ) ; } else { throw new IllegalStateException ( "queue is closed" ) ; } } finally { lock . unlock ( ) ; } }
Returns the next element in the queue. If the queue is empty, this method
waits until at least one element is added.

<p>The method throws an {@code IllegalStateException} if the queue is closed.
Checking whether the queue is open and removing the next element is one atomic operation.

@return The next element in the queue, never null.

@throws IllegalStateException Thrown, if the queue is closed.
@throws InterruptedException Throw, if the thread is interrupted while waiting for an
element to be added.