ArrayBlockingQueue.offer(E e) has the following syntax.
public boolean offer(E e)
In the following code shows how to use ArrayBlockingQueue.offer(E e) method.
import java.util.Iterator; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; //ww w . j av a 2 s . c o m public class Main { 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); } queue.offer(9999); System.out.println(queue); } }
The code above generates the following result.