@Override
  public Set<Resource> populateResources(Set<Resource> resources, Request request, Predicate predicate)
      throws SystemException {

    if(!checkAuthorizationForMetrics(resources, clusterNamePropertyId)) {
      return resources;
    }

    // Get a valid ticket for the request.
    final Ticket ticket = new Ticket();

    // in most cases, the buffered completion service will not be utlized for
    // its advantages since the worker queue is unbounded. However, if is
    // configured with a boundary, then the buffered service ensures that no
    // requests are discarded.
    final CompletionService<Resource> completionService =
      new BufferedThreadPoolExecutorCompletionService<>(EXECUTOR_SERVICE);

    // In a large cluster we could have thousands of resources to populate here.
    // Distribute the work across multiple threads.
    for (Resource resource : resources) {
      completionService.submit(
          getPopulateResourceCallable(resource, request, predicate, ticket));
    }

    Set<Resource> keepers = new HashSet<>();
    try {
      for (int i = 0; i < resources.size(); ++i) {
        Future<Resource> resourceFuture = completionService.poll(COMPLETION_SERVICE_POLL_TIMEOUT,
            TimeUnit.MILLISECONDS);

        if (resourceFuture == null) {
          // its been more than the populateTimeout since the last callable
          // completed ...
          // invalidate the ticket to abort the threads and don't wait any
          // longer
          ticket.invalidate();
          LOG.error("Timed out after waiting {}ms waiting for request {}",
              COMPLETION_SERVICE_POLL_TIMEOUT, request);

          // stop iterating
          break;
        }

        // future should already be completed... no need to wait on get
        Resource resource = resourceFuture.get();
        if (resource != null) {
          keepers.add(resource);
        }
      }
    } catch (InterruptedException e) {
      logException(e);
    } catch (ExecutionException e) {
      rethrowSystemException(e.getCause());
    }

    return keepers;
  }
Generates thread pool with default parameters
ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/ThreadPoolEnabledPropertyProvider.java