code: void stopAfter(int remainingScans) {
  		Thread thread;
  		synchronized (this.monitor) {
  			thread = this.watchThread;
  			if (thread != null) {
  				this.remainingScans.set(remainingScans);
  				if (remainingScans <= 0) {
  					thread.interrupt();
  				}
  			}
  			this.watchThread = null;
  		}
  		if (thread != null && Thread.currentThread() != thread) {
  			try {
  				thread.join();
  			}
  			catch (InterruptedException ex) {
  				Thread.currentThread().interrupt();
  			}
  		}
  	}
docs: Stop monitoring the source folders.
  @param remainingScans the number of remaining scans