class ParallelIndividualCompleter extends SequentialIndividualCompleter implements OptimizerStateListener {

	@Override
	public void complete(Iterable<? extends Individual> iterable) throws TerminationException {

		try {

			List<Future<Void>> returns = new ArrayList<>();

			for (Individual individual : iterable) {
				if (individual.getState() != Individual.State.EVALUATED) {
					returns.add(executor.submit(new Complete(individual, control)));
				}
			}

			for (Future<Void> future : returns) {
				try {
					future.get();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		} catch (ExecutionException ex) {
			executor.shutdownNow();
			if (ex.getCause() instanceof TerminationException) {
				throw (TerminationException) ex.getCause();
			}
			throw new RuntimeException(ex);
		}
	}

	@Inject public  ParallelIndividualCompleter(Control control, Decoder<Genotype, Object> decoder, Evaluator<Object> evaluator,
			@Constant(value = "maxThreads", namespace = ParallelIndividualCompleter.class) int maxThreads);

}