@SuppressWarnings("serial")
  private void startWaitOnLocatorToStopThread(VM vm) {
    vm.invoke("create wait-on-locator-to-stop thread", () -> {
      final Locator loc = Locator.getLocator();
      assertNotNull(loc);
      waitOnLocatorToStopThread = new Thread(() -> {
        try {
          ((InternalLocator) loc).waitToStop();
        } catch (InterruptedException e) {
          System.out.println(Thread.currentThread().getName() + " interrupted - exiting");
        }
      }, "ReconnectDUnitTest_WaitOnLocatorToStop_thread");
      waitOnLocatorToStopThread.setDaemon(true);
      waitOnLocatorToStopThread.start();
      System.out.println("created wait-on-locator-to-stop thread: " + waitOnLocatorToStopThread);
    });
  }
this will throw an exception if location services aren't running
geode-core/src/distributedTest/java/org/apache/geode/cache30/ReconnectDUnitTest.java