Java ArrayBlockingQueue.poll()
Syntax
ArrayBlockingQueue.poll() has the following syntax.
public E poll()
Example
In the following code shows how to use ArrayBlockingQueue.poll() method.
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
// w w w . j av a 2 s.co m
public class Main {
public static void main(String[] argv) throws Exception {
int capacity = 10;
BlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(capacity);
for (int i = 0; i < 10; i++) {
queue.add(i);
}
System.out.println(queue.poll());
}
}
The code above generates the following result.