code: private SwingBackgroundTask<List<String>> createTask(final Collection<String> cities)
      {
          final TravellingSalesmanStrategy strategy = strategyPanel.getStrategy();
          return new SwingBackgroundTask<List<String>>()
          {
              private long elapsedTime = 0;
  
              @Override
              protected List<String> performTask()
              {
                  long startTime = System.currentTimeMillis();
                  List<String> result = strategy.calculateShortestRoute(cities, executionPanel);
                  elapsedTime = System.currentTimeMillis() - startTime;
                  return result;
              }
  
              @Override
              protected void postProcessing(List<String> result)
              {
                  executionPanel.appendOutput(createResultString(strategy.getDescription(),
                                                                 result,
                                                                 evaluator.getFitness(result, null),
                                                                 elapsedTime));
                  setEnabled(true);
              }
          };
      }
docs: Helper method to create a background task for running the travelling
  salesman algorithm.
  @param cities The set of cities to generate a route for.
  @return A Swing task that will execute on a background thread and update
  the GUI when it is done.