List of usage examples for java.util.concurrent TransferQueue put
void put(E e) throws InterruptedException;
From source file:TQProducer.java
public static void main(String[] args) { final TransferQueue<Integer> tQueue = new LinkedTransferQueue<>(); final AtomicInteger sequence = new AtomicInteger(); for (int i = 0; i < 5; i++) { try {/*from w w w. j a v a 2s. c o m*/ tQueue.put(sequence.incrementAndGet()); System.out.println("Initial queue: " + tQueue); new TQProducer("Producer-1", tQueue, sequence).start(); new TQConsumer("Consumer-1", tQueue).start(); } catch (InterruptedException e) { e.printStackTrace(); } } }