code: public void then(PromiseListener listener) {
          if (listener == null) {
              return;
          }
          listeners.add(listener);
          if (isSettled()) {
              notifyListener(listener);
          }
      }
docs: Adds a listener that is called once the promise is settled. NOTE: If the
  promise is already settled when adding the listener, the thread adding
  the listener will be used to execute the listener.
  @param listener the listener that will be called once the promise is settled