private static long performanceRun(int runNumber, Queue<Integer> queue) throws InterruptedException { long start = System.nanoTime(); Thread thread = new Thread(new Producer(queue)); thread.start(); Integer result; int i = REPETITIONS; do { while (null == (result = queue.poll())) { Thread.yield(); } } while (0 != --i); thread.join(); long duration = System.nanoTime() - start; long ops = (REPETITIONS * 1000L * 1000L * 1000L) / duration; String qName = queue.getClass().getSimpleName(); System.out.format("%d - ops/sec=%,d - %s result=%d\n", runNumber, ops, qName, result); return ops; } public static class Producer implements Runnable { private final Queue<Integer> queue; public Producer(Queue<Integer> queue) { this.queue = queue; } public void run() { int i = REPETITIONS; do { while (!queue.offer(TEST_VALUE)) { Thread.yield(); } } while (0 != --i); } }