Example usage for java.util.concurrent ArrayBlockingQueue iterator

List of usage examples for java.util.concurrent ArrayBlockingQueue iterator

Introduction

In this page you can find the example usage for java.util.concurrent ArrayBlockingQueue iterator.

Prototype

public Iterator<E> iterator() 

Source Link

Document

Returns an iterator over the elements in this queue in proper sequence.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int capacity = 10;
    ArrayBlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(capacity);

    for (int i = 0; i < 10; i++) {
        queue.add(i);/*from   w  w  w.ja  v a 2s  . c  o m*/
    }
    Iterator<Integer> it = queue.iterator();
    while (it.hasNext()) {
        System.out.println(it.next());
    }
}