List of usage examples for java.util.concurrent ArrayBlockingQueue add
public boolean add(E e)
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 .ja va 2s . co 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 ava 2 s .c om*/ }
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 . ja v a 2s . 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 . ja va2s . com*/ 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 va 2 s . c o m*/ queue.offer(9999); System.out.println(queue); }
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 www .j av a 2 s. c o m System.out.println(Arrays.toString(queue.toArray())); }
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 www. j ava 2 s . co m*/ queue.offer(9999, 10, TimeUnit.MINUTES); System.out.println(queue); }
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 .j ava 2 s . co m System.out.println(queue.remainingCapacity()); }
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 www . j a va2s .c om*/ System.out.println(Arrays.toString(queue.toArray(new Integer[queue.size()]))); }
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 ww . ja va 2 s . c om*/ System.out.println(queue.poll(10, TimeUnit.MINUTES)); }