Java Code Examples for java.util.concurrent.LinkedBlockingQueue#element()

The following examples show how to use java.util.concurrent.LinkedBlockingQueue#element() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * element returns next element, or throws NSEE if empty
 */
public void testElement() {
    LinkedBlockingQueue q = populatedQueue(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(i, q.element());
        assertEquals(i, q.poll());
    }
    try {
        q.element();
        shouldThrow();
    } catch (NoSuchElementException success) {}
}
 
Example 2
Source Project: j2objc   File: LinkedBlockingQueueTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * element returns next element, or throws NSEE if empty
 */
public void testElement() {
    LinkedBlockingQueue q = populatedQueue(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(i, q.element());
        assertEquals(i, q.poll());
    }
    try {
        q.element();
        shouldThrow();
    } catch (NoSuchElementException success) {}
}