private ListenableFuture<List<Boolean>> createSessions(final int sessionCount) {
    Preconditions.checkArgument(sessionCount > 0);

    Collection<Callable<Boolean>> tasks =
        Stream.generate(() -> (new CreateSessionCallable(Optional.ofNullable(parentSessionState), sessionObjFactory, deltaRemaining)))
            .limit(sessionCount).collect(Collectors.toList());

    List<ListenableFuture<Boolean>> futures = new ArrayList<>(tasks.size());
    for (Callable<Boolean> task : tasks) {
      futures.add(executorService.submit(task));
    }

    return Futures.allAsList(futures);
  }
Create {@code sessionCount} number of sessions, doing so in parallel, using
a maximum of {@code maxParallel} threads.

@param sessionCount The number of sessions to launch
@return A single {@code future} which carries all of the outputs from each
        session launch
@throws IllegalArgumentException if {@code sessionCount} or
          {@code maxParallel} is less than or equal to zero
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionPool.java