code: protected List<EvaluatedCandidate<T>> evaluatePopulation(List<T> population)
      {
          List<EvaluatedCandidate<T>> evaluatedPopulation = new ArrayList<EvaluatedCandidate<T>>(population.size());
  
          if (singleThreaded) // Do fitness evaluations on the request thread.
          {
              for (T candidate : population)
              {
                  evaluatedPopulation.add(new EvaluatedCandidate<T>(candidate,
                                                                    fitnessEvaluator.getFitness(candidate, population)));
              }
          }
          else
          {
              // Divide the required number of fitness evaluations equally among the
              // available processors and coordinate the threads so that we do not
              // proceed until all threads have finished processing.
              try
              {
                  List<T> unmodifiablePopulation = Collections.unmodifiableList(population);
                  List<Future<EvaluatedCandidate<T>>> results = new ArrayList<Future<EvaluatedCandidate<T>>>(population.size());
                  // Submit tasks for execution and wait until all threads have finished fitness evaluations.
                  for (T candidate : population)
                  {
                      results.add(getSharedWorker().submit(new FitnessEvalutationTask<T>(fitnessEvaluator,
                                                                                         candidate,
                                                                                         unmodifiablePopulation)));
                  }
                  for (Future<EvaluatedCandidate<T>> result : results)
                  {
                      evaluatedPopulation.add(result.get());
                  }
              }
              catch (ExecutionException ex)
              {
                  throw new IllegalStateException("Fitness evaluation task execution failed.", ex);
              }
              catch (InterruptedException ex)
              {
                  // Restore the interrupted status, allows methods further up the call-stack
                  // to abort processing if appropriate.
                  Thread.currentThread().interrupt();
              }
          }
  
          return evaluatedPopulation;
      }
docs: Takes a population, assigns a fitness score to each member and returns
  the members with their scores attached, sorted in descending order of
  fitness (descending order of fitness score for natural scores, ascending
  order of scores for non-natural scores).
  @param population The population to evaluate (each candidate is assigned
  a fitness score).
  @return The evaluated population (a list of candidates with attached fitness
  scores).