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

The following examples show how to use java.util.concurrent.LinkedBlockingQueue#element() . 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
Source File: LinkedBlockingQueueTest.java    From openjdk-jdk9 with GNU General Public License v2.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) {}
}
 
Example 2
Source File: LinkedBlockingQueueTest.java    From j2objc with 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) {}
}