public void waitToStop() throws InterruptedException {
    boolean restarted;
    do {
      DistributedSystem system = internalDistributedSystem;
      restarted = false;
      membershipLocator.waitToShutdown();
      if (stoppedForReconnect) {
        // there would be a gap between stoppedForReconnect being to true and isReconnecting()
        // being true, if system.waitUntilReconnected happened in between, this method would return
        // false immediately. We should also to wait till system is reconnecting here
        // in this call to prevent that.
        logger.info("waiting for distributed system to disconnect and reconnect...");
        while (system.isConnected() || !system.isReconnecting()) {
          Thread.sleep(1000);
        }

        logger.info("waiting for distributed system to be reconnected...");
        try {
          restarted = system.waitUntilReconnected(-1, TimeUnit.SECONDS);
        } catch (CancelException e) {
          // reconnect attempt failed
        }
        if (restarted) {
          logger.info("system restarted");
        } else {
          logger.info("system was not restarted");
        }
        Thread restartThread = this.restartThread;
        if (restartThread != null) {
          logger.info("waiting for services to restart...");
          restartThread.join();
          this.restartThread = null;
          logger.info("done waiting for services to restart");
        }
      }
    } while (restarted);
  }
This method returns when the locator stops. This method should not return while locator is
disconnected/reconnected

Waits for a locator to be told to stop.

@throws InterruptedException thrown if the thread is interrupted
geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java