public class ConcurrentQueuePerfTest { ... public static void main(final String[] args) throws Exception { // build a queue for our spec, this is an SPSC, bounded etc. final ConcurrentQueue<Integer> queue = ConcurrentQueueFactory.newQueue( new ConcurrentQueueSpec(1, 1, QUEUE_CAPACITY, Growth.BOUNDED, Ordering.FIFO, Preference.THROUGHPUT)); ... performanceRun(i, queue); ... } private static long performanceRun(final int runNumber, final ConcurrentQueue<Integer> queue) throws Exception { // this is the consumer thread, so get a consumer final ConcurrentQueueConsumer<Integer> consumer = queue.consumer(); final Thread thread = new Thread(new Producer(queue)); thread.start(); Integer result; int i = REPETITIONS; do { while (null == (result = consumer.poll())) { Thread.yield(); } } while (0 != --i); thread.join(); ... } public static class Producer implements Runnable { private final ConcurrentQueue<Integer> queue; public Producer(final ConcurrentQueue<Integer> queue) { this.queue = queue; } public void run() { // this is the producer thread, get a producer final ConcurrentQueueProducer<Integer> producer = queue.producer(); int i = REPETITIONS; do { while (!producer.offer(TEST_VALUE)) { Thread.yield(); } } while (0 != --i); } } }