Example usage for java.util.concurrent ArrayBlockingQueue clear

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

Introduction

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

Prototype

public void clear() 

Source Link

Document

Atomically removes all of the elements from this queue.

Usage

From source file:Main.java

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

    for (int i = 0; i < 100; i++) {
        queue.add(i);//from   w  ww.j  a v a2 s  .  c o m
    }
    queue.clear();
}

From source file:Main.java

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

    for (int i = 0; i < 100; i++) {
        queue.add(i);/*from w  w  w . ja  va  2s .c om*/
    }
    System.out.println(queue.contains(5));
    queue.clear();
    System.out.println(queue.contains(5));
}