code: public static void connectAsynchronously(Options options, boolean reconnectOnConnect)
              throws InterruptedException {
  
          if (options.getConnectionListener() == null) {
              throw new IllegalArgumentException("Connection Listener required in connectAsynchronously");
          }
  
          Thread t = new Thread(() -> {
              try {
                  NatsImpl.createConnection(options, reconnectOnConnect);
              } catch (Exception ex) {
                  if (options.getErrorListener() != null) {
                      options.getErrorListener().exceptionOccurred(null, ex);
                  }
              }
          });
          t.setName("NATS - async connection");
          t.start();
      }
docs: Try to connect in another thread, a connection listener is required to get
  the connection.
  
  <p>Normally connect will loop through the available servers one time. If
  reconnectOnConnect is true, the connection attempt will repeat based on the
  settings in options, including indefinitely.
  
  <p>If there is an exception before a connection is created, and the error
  listener is set, it will be notified with a null connection.
  
  <p><strong>This method is experimental, please provide feedback on its value.</strong>
  
  @param options            the connection options
  @param reconnectOnConnect if true, the connection will treat the initial
  connection as any other and attempt reconnects on
  failure
  
  @throws IllegalArgumentException if no connection listener is set in the options
  @throws InterruptedException if the current thread is interrupted