Example usage for java.util.concurrent ArrayBlockingQueue ArrayBlockingQueue

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

Introduction

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

Prototype

public ArrayBlockingQueue(int capacity) 

Source Link

Document

Creates an ArrayBlockingQueue with the given (fixed) capacity and default access policy.

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);/*from  w  w w  . jav a2 s .  co m*/
    }

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

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 w w  .j av a2s  . c  om*/
    }

    System.out.println(queue.remove(new Integer(0)));
}

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);/*from   w  ww.  j  a  va2s  .  co  m*/
    }

    // System.out.println(queue.removeFirstOccurrence(new Integer(0)));
}

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);//from www .j av  a 2 s  . co  m
    }

    System.out.println(queue.contains(0));
}

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);//  www .ja v a 2s  .  c om
    }

    //System.out.println(queue.removeLastOccurrence(new Integer(0)));
}

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);/*w  w  w  .j a  va2  s. c  o  m*/
    }
    System.out.println(queue.poll());
}

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  av a 2s. com*/
    }

}

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   ww  w .java2s . c  o m
    }
    queue.clear();
}

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   ww  w  . j a  v a 2  s.c  o  m
    }

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

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);/*w  ww.j  a va2s.  c o m*/
    }

    System.out.println(queue.remove(0));
    System.out.println(queue);
}