### Question:
ConcurrentQ { public Collection<QResult<I, R>> waitForResults() throws InterruptedException { lock.lockInterruptibly(); try { tracker.waitUntilDone(); Collection<QResult<I, R>> returnValue = resultList; resultList = new LinkedList<>(); return returnValue; } 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 testWaitWithTimeOutOnEmptyQueueDoesntBlock() throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); Thread runner = new Thread(() -> { try { q.waitForResults(3000, TimeUnit.MILLISECONDS); latch.countDown(); } catch (InterruptedException e) { } }); runner.start(); assertTrue("Timed-out waiting for Thread to finish. It must be blocking on an empty queue", latch.await(100, TimeUnit.MILLISECONDS)); }
@Test public void testWaitForeverOnEmptyQueueDoesntBlock() throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); Thread runner = new Thread(() -> { try { q.waitForResults(); latch.countDown(); } catch (InterruptedException e) { } }); runner.start(); assertTrue("Timed-out waiting for Thread to finish. It must be blocking on an empty queue", latch.await(100, TimeUnit.MILLISECONDS)); }