code: public void release(T result) {
          ArrayList<CompletableFuture<T>> toComplete = null;
          synchronized (lock) {
              if (!waitingFutures.isEmpty()) {
                  toComplete = new ArrayList<>(waitingFutures);
                  waitingFutures.clear();
              }
              e = null;
              this.result = result;
              released = true;
          }
          if (toComplete != null) {
              for (CompletableFuture<T> f : toComplete) {
                  f.complete(result);
              }
          }
      }
docs: Complete all waiting futures, and all future calls to register be notified immediately. If release is
  called twice consecutively the second value will be the one passed to future callers of
  {@link #register(CompletableFuture)}
  
  @param result The result to pass to waiting futures.