public FileStarted checkForTimedOutMillis(long staleThresholdMillis) {
        //if there isn't a current file, don't bother obtaining lock
        if (currentFile == null) {
            return null;
        }
        //if threshold is < 0, don't even look.
        if (staleThresholdMillis < 0) {
            return null;
        }
        synchronized (lock) {
            //check again once the lock has been obtained
            if (currentState != STATE.ACTIVELY_CONSUMING && currentState != STATE.ASKED_TO_SHUTDOWN) {
                return null;
            }
            FileStarted tmp = currentFile;
            if (tmp == null) {
                return null;
            }
            if (tmp.getElapsedMillis() > staleThresholdMillis) {
                setEndedState(STATE.TIMED_OUT);
                LOG.error("{}", getXMLifiedLogMsg(TIMED_OUT, tmp.getResourceId(), ELAPSED_MILLIS, Long.toString(tmp.getElapsedMillis())));
                return tmp;
            }
        }
        return null;
    }
Checks to see if the currentFile being processed (if there is one)
should be timed out (still being worked on after staleThresholdMillis).
<p>
If the consumer should be timed out, this will return the currentFile and
set the state to TIMED_OUT.
<p>
If the consumer was already timed out earlier or
is not processing a file or has been working on a file
for less than #staleThresholdMillis, then this will return null.
<p>

@param staleThresholdMillis threshold to determine whether the consumer has gone stale.
@return null or the file started that triggered the stale condition
tika-batch/src/main/java/org/apache/tika/batch/FileResourceConsumer.java