private void stop(boolean interruptIfAlive) {
    synchronized (HostStatSampler.class) {
      callbackSampler.stop();
      if (statThread == null) {
        return;
      }

      stopRequested = true;
      synchronized (this) {
        notifyAll();
      }
      try {
        statThread.join(5000);
      } catch (InterruptedException ignore) {
        // It is important that we shutdown so we'll continue trying for another 2 seconds
        try {
          statThread.join(2000);
        } catch (InterruptedException ignored) {
        } finally {
          Thread.currentThread().interrupt();
        }
      } finally {
        if (statThread.isAlive()) {
          if (interruptIfAlive) {
            // It is still alive so interrupt the thread
            statThread.interrupt();
            stop(false);
          } else {
            logger.warn(LogMarker.STATISTICS_MARKER,
                "HostStatSampler thread could not be stopped during shutdown.");
          }
        } else {
          stopRequested = false;
          statThread = null;
        }
      }
    }
  }
Tell this service's main thread to terminate.
geode-core/src/main/java/org/apache/geode/internal/statistics/HostStatSampler.java