### Question:
ConcurrentQ { public void waitUntilDone() throws InterruptedException, Exception { lock.lockInterruptibly(); try { checkException(); while (!isEmpty()) { tracker.waitForNext(); checkException(); } } 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 testWaitUntilDone() throws Exception { CountDownLatch waitLatch = new CountDownLatch(1); List<TestItem> workList = new ArrayList<>(); workList.add(new LatchTestItem("1", waitLatch, FAST_EXECUTION)); workList.add(new TestItem("2", FAST_EXECUTION)); workList.add(new TestItem("3", FAST_EXECUTION)); workList.add(new TestItem("4", FAST_EXECUTION)); q.add(workList); CheckpointRunner checkpointRunner = new CheckpointRunner(new WaitUntilDoneCallable()); assertTrue("Thread did not start", checkpointRunner.waitForStart(500)); assertTrue("waitUntilDone() call did not wait for all items", !checkpointRunner.hasFinished()); waitLatch.countDown(); assertTrue("Timed-out waiting for Thread to finish. It must be blocking on an empty queue", checkpointRunner.waitForFinish(500)); checkpointRunner = new CheckpointRunner(new WaitUntilDoneCallable()); assertTrue("Timed-out waiting for Thread to finish. It must be blocking on an empty queue", checkpointRunner.waitForFinish(3000)); }