code: public void waitForCompletion() throws Exception {
      LOG.info("Waiting for the Job Driver to complete.");
      try {
        synchronized (this) {
          this.wait();
        }
      } catch (final InterruptedException ex) {
        LOG.log(Level.WARNING, "Waiting for result interrupted.", ex);
      }
      this.reef.close();
      this.controlListener.close();
    }
docs: Wait for the job to complete.