code: @Override
      public void run() {
          do {
  
              // Scan for directories:
              try {
                  log.info("Scanning for directories under {}", root);
                  Files.walkFileTree(root, new Visitor());
              } catch (IOException e) {
                  log.info("Error in scanning for directories to monitor:");
                  e.printStackTrace();
              }
  
              // Block until notified that a new scan is needed:
              synchronized (Scanner.class) {
                  try {
                      Scanner.class.wait();
                  } catch (InterruptedException e) {
                      log.info("Scanner interrupted:");
                      e.printStackTrace();
                  }
              }
  
          } while (true);
  
      }
docs: Infinite loop that scans {@link #root} and then blocks until notified
  that a new scan is needed.