@Override
    public Iterator<FetchEmitTuple> iterator() {
        if (futureTask != null) {
            throw new IllegalStateException("Can't call iterator more than once!");
        }
        futureTask = new FutureTask<>(this);
        queue = new ArrayBlockingQueue<>(queueSize);
        new Thread(futureTask).start();
        return new TupleIterator();
    }
Abstract class that handles the testing for timeouts/thread safety
issues.  Concrete classes implement the blocking {@link #enqueue()}.
If there's an exception in the enqueuing thread, this will throw
a RuntimeException.  It will throw an IllegalStateException if
next() is called after hasNext() has returned false.
tika-core/src/main/java/org/apache/tika/pipes/pipesiterator/PipesIterator.java