@Override
    public void run() {
      try {
        LOG.debug("{} thread started", getName());
        if (
          !compareAndSetState(FileChangeWatcher.State.STARTING, FileChangeWatcher.State.RUNNING)
        ) {
          // stop() called shortly after start(), before
          // this thread started running.
          FileChangeWatcher.State state = FileChangeWatcher.this.getState();
          if (state != FileChangeWatcher.State.STOPPING) {
            throw new IllegalStateException("Unexpected state: " + state);
          }
          return;
        }
        runLoop();
      } catch (Exception e) {
        LOG.warn("Error in runLoop()", e);
        throw new RuntimeException(e);
      } finally {
        LOG.debug("{} thread finished", getName());
        FileChangeWatcher.this.setState(FileChangeWatcher.State.STOPPED);
      }
    }
Inner class that implements the watcher thread logic.
hbase-common/src/main/java/org/apache/hadoop/hbase/io/FileChangeWatcher.java