Java ArrayBlockingQueue.clear()

Syntax

ArrayBlockingQueue.clear() has the following syntax.

public void clear()

Example

In the following code shows how to use ArrayBlockingQueue.clear() method.


import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
/* w  w  w  . j av a2s .  co  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);
    }
    queue.clear();
  }
}




















Home »
  Java Tutorial »
    java.util.concurrent »




ArrayBlockingQueue
BlockingDeque
CountDownLatch
CyclicBarrier
TimeUnit