Example usage for java.util.concurrent BlockingQueue element

List of usage examples for java.util.concurrent BlockingQueue element

Introduction

In this page you can find the example usage for java.util.concurrent BlockingQueue element.

Prototype

E element();

Source Link

Document

Retrieves, but does not remove, the head of this queue.

Usage

From source file:Main.java

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);/*  w  ww.  j  a  v a2  s  . c om*/
    }

    System.out.println(queue.element());
}