code: public LauncherStatus waitForStatus(final long waitTime, final LauncherStatus... statuses) {
  
      final long endTime = System.currentTimeMillis() + waitTime;
  
      final HashSet<LauncherStatus> statSet = new HashSet<>(statuses.length * 2);
      Collections.addAll(statSet, statuses);
      Collections.addAll(statSet, LauncherStatus.FAILED, LauncherStatus.FORCE_CLOSED);
  
      LOG.log(Level.FINEST, "Wait for status: {0}", statSet);
      final LauncherStatus finalStatus;
  
      synchronized (this) {
        while (!statSet.contains(this.status)) {
          try {
            final long delay = endTime - System.currentTimeMillis();
            if (delay <= 0) {
              break;
            }
            LOG.log(Level.FINE, "Wait for {0} milliSeconds", delay);
            this.wait(delay);
          } catch (final InterruptedException ex) {
            LOG.log(Level.FINE, "Interrupted: {0}", ex);
          }
        }
  
        finalStatus = this.status;
      }
  
      LOG.log(Level.FINEST, "Final status: {0}", finalStatus);
      return finalStatus;
    }
docs: Wait for one of the specified statuses of the REEF job.
  This method is called after the job is submitted to the RM via submit().
  @param waitTime wait time in milliseconds.
  @param statuses array of statuses to wait for.
  @return the state of the job after the wait.