code: public static Future<?> execute(final CuratorFramework client, final Runnable runAfterConnection) throws Exception
      {
          //Block until connected
          final ExecutorService executor = ThreadUtils.newSingleThreadExecutor(ThreadUtils.getProcessName(runAfterConnection.getClass()));
          Runnable internalCall = new Runnable()
          {
              @Override
              public void run()
              {
                  try
                  {
                      client.blockUntilConnected();
                      runAfterConnection.run();
                  }
                  catch ( Exception e )
                  {
                      ThreadUtils.checkInterrupted(e);
                      log.error("An error occurred blocking until a connection is available", e);
                  }
                  finally
                  {
                      executor.shutdown();
                  }
              }
          };
          return executor.submit(internalCall);
      }
docs: Spawns a new new background thread that will block until a connection is available and
  then execute the 'runAfterConnection' logic
  
  @param client             The curator client
  @param runAfterConnection The logic to run
  @return future of the task so it can be canceled, etc. if needed