private void runLoop() throws IOException {
      while (FileChangeWatcher.this.getState() == FileChangeWatcher.State.RUNNING) {
        BasicFileAttributes attributes = Files.readAttributes(filePath, BasicFileAttributes.class);
        boolean modified = false;
        synchronized (lastModifiedTimeLock) {
          FileTime maybeNewLastModifiedTime = attributes.lastModifiedTime();
          if (!lastModifiedTime.equals(maybeNewLastModifiedTime)) {
            modified = true;
            lastModifiedTime = maybeNewLastModifiedTime;
          }
        }

        // avoid calling callback while holding lock
        if (modified) {
          try {
            callback.callback(filePath);
          } catch (Throwable e) {
            LOG.error("Error from callback", e);
          }
        }

        try {
          Thread.sleep(pollInterval.toMillis());
        } catch (InterruptedException e) {
          LOG.debug("Interrupted", e);
          Thread.currentThread().interrupt();
          return;
        }
      }
    }
Inner class that implements the watcher thread logic.
hbase-common/src/main/java/org/apache/hadoop/hbase/io/FileChangeWatcher.java