protected Thread addToQueue(final int numberOfItemsToAdd, final long pauseBetweenItemsInMillis,
                                final boolean start, final boolean markDone, final int itemsToWaitFor) throws Exception {
        final CountDownLatch latch = new CountDownLatch(itemsToWaitFor);
        final Thread t = new Thread(() -> {
            boolean done = false;
            for (int ix = 0; ix < numberOfItemsToAdd && !done; ix++) {
                try {
                    if (Thread.currentThread().isInterrupted()) throw new InterruptedException();
                    final int currentIndex = ix;
                    pool.submit(() -> {
                        final Result result = new Result("test-" + currentIndex);
                        resultQueue.add(result);
                        latch.countDown();
                    }).get();
                    TimeUnit.MILLISECONDS.sleep(pauseBetweenItemsInMillis);
                } catch (Exception ie) {
                    done = true;
                }
            }

            if (markDone) resultQueue.markComplete();

        }, "ResultQueueTest-job-submitter");

        if (start) t.start();

        // wait for the number of items requested to be added to the queue
        latch.await();

        return t;
    }
Adds some test items to the {@link ResultQueue}. This method has the potential to block if the
{@code itemsToWaitFor > 0}.

@param numberOfItemsToAdd the number of items to add in total
@param pauseBetweenItemsInMillis amount of time to wait between additions to the {@link ResultQueue}
@param start set to {@code true} to start the thread
@param markDone force mark the queue as complete
@param itemsToWaitFor block until this many items have been added to the {@link ResultQueue}
@return the thread that is doing the work of adding to the queue
@throws Exception
gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/AbstractResultQueueTest.java