Java Collection Tutorial - Java ArrayBlockingQueue.add(E e)








Syntax

ArrayBlockingQueue.add(E e) has the following syntax.

public boolean add(E e)

Example

In the following code shows how to use ArrayBlockingQueue.add(E e) method.

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
//w w  w .  ja v  a2  s.c o m
public class Main {
  public static void main(String[] argv) throws Exception {
    int capacity = 100;
    BlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(capacity);

    for (int i = 0; i < 100; i++) {
      queue.add(i);
    }
    
  }
}