### Question:
SingleConsumerNonblockingProducerDelayQueue extends SingleConsumerNonblockingProducerQueue<E> { @Override public E take() throws InterruptedException { E e = q.peek(); long delayNanos; if (e == null || getDelay(e) > 0) { sync.register(); try { e = q.peek(); delayNanos = getDelay(e); while (delayNanos > 0) { sync.awaitNanos(delayNanos); e = q.peek(); delayNanos = getDelay(e); } return q.poll(); } finally { sync.unregister(); } } else { e = q.poll(); assert e != null; return e; } } SingleConsumerNonblockingProducerDelayQueue(); @Override E poll(); @Override E take(); @Override E poll(long timeout, TimeUnit unit);  }### Answer:
@Test public void testTake() throws Exception { q.offer(DelayedValue.instance(SEQUENCED, 2, 100)); q.offer(DelayedValue.instance(SEQUENCED, 1, 50)); q.offer(DelayedValue.instance(SEQUENCED, 3, 150)); DelayedValue dv; final long start = System.nanoTime(); dv = q.take(); assertThat(dv.getValue(), is(1)); dv = q.take(); assertThat(dv.getValue(), is(2)); dv = q.take(); assertThat(dv.getValue(), is(3)); final long elapsedMillis = TimeUnit.MILLISECONDS.convert(System.nanoTime() - start, TimeUnit.NANOSECONDS); assertTrue("elapsed: " + elapsedMillis, elapsedMillis > 140 && elapsedMillis < 300); }