code: public void setWaitForExternalEvents(boolean shouldWait) {
          if (waitForExternalEvents && !shouldWait) {
              waitForExternalEvents = false;
              recentlyEnqueuedExternalEvents.add(NO_MORE_WAIT_EXTERNAL);
          } else {
              waitForExternalEvents = shouldWait;
          }
      }
docs: Sets whether this program waits for external events or not.
  
  When set to {@code false}, when no events are available for selection,
  the program terminates.
  
  @param shouldWait {@code true} causes the system to wait for external events. {@code false} causes it to not wait.