下面列出了java.util.concurrent.LinkedBlockingQueue#element ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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) {}
}
/**
* 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) {}
}