### Question:
ConcurrentQ { public QResult<I, R> waitForNextResult() throws InterruptedException { if (!collectResults) { throw new IllegalStateException( "Can't wait for next result when not collecting results"); } lock.lockInterruptibly(); try { if (resultList.isEmpty()) { if (isEmpty()) { return null; } tracker.waitForNext(); } return resultList.pop(); } finally { lock.unlock(); } } ConcurrentQ(String name, QCallback<I, R> callback);  ConcurrentQ(QCallback<I, R> callback, Queue<I> queue, GThreadPool threadPool,
			QItemListener<I, R> listener, boolean collectResults, int maxInProgress,
			boolean jobsReportProgress); synchronized void addProgressListener(QProgressListener<I> listener); synchronized void removeProgressListener(QProgressListener<I> listener); void setMonitor(TaskMonitor monitor, boolean cancelClearsAllItems); void add(Collection<I> items); void add(Iterator<I> iterator); void offer(Iterator<I> iterator); void add(I item); boolean isEmpty(); Collection<QResult<I, R>> waitForResults(); QResult<I, R> waitForNextResult(); void waitUntilDone(); Collection<QResult<I, R>> waitForResults(long timeout, TimeUnit unit); List<I> cancelAllTasks(boolean interruptRunningTasks); List<I> removeUnscheduledJobs(); void cancelScheduledJobs(); void dispose(); boolean waitUntilDone(long timeout, TimeUnit unit);  }### Answer:
@Test public void testWaitForNextResult() throws Exception { CountDownLatch waitLatch = new CountDownLatch(1); CountDownLatch waitLatch2 = new CountDownLatch(1); List<TestItem> workList = new ArrayList<>(); workList.add(new LatchTestExceptionItem("1", waitLatch, FAST_EXECUTION)); workList.add(new TestItem("2", FAST_EXECUTION)); workList.add(new LatchTestItem("3", waitLatch2, FAST_EXECUTION)); q.add(workList); CheckpointRunner checkpointRunner = new CheckpointRunner(new WaitForNextCallable()); QResult<TestItem, TestResult> qResult = checkpointRunner.getResult(); assertEquals("2", qResult.getResult().getItemName()); waitLatch.countDown(); checkpointRunner = new CheckpointRunner(new WaitForNextCallable()); qResult = checkpointRunner.getResult(); assertTrue(qResult.hasError()); waitLatch2.countDown(); checkpointRunner = new CheckpointRunner(new WaitForNextCallable()); qResult = checkpointRunner.getResult(); TestResult result = qResult.getResult(); assertEquals("3", result.getItemName()); }