class ParallelFunctionEvaluator implements FunctionEvaluator {

    public synchronized void evaluate(Population[] populations, Function function) {
        this.barrier.reset();

        int totalIndividuals = PopulationUtils.sumSizes(populations);
        int individualsPerThread = totalIndividuals / numProcessors;
        PositionDescriptor from = new PositionDescriptor(0, 0);
        PositionDescriptor toExclusive;
        if (individualsPerThread > 0){
            int currentIndividualExclusive = individualsPerThread;
            for (int i = 0; i < numProcessors - 1; i++){
                toExclusive = getIndexForIndividual(populations, currentIndividualExclusive);
                new Thread(new EvaluatorThread(this.barrier, function, populations, from, toExclusive)).start();

                from = getIndexForIndividual(populations, currentIndividualExclusive);
                currentIndividualExclusive += individualsPerThread;
            }
        }
        // final worker is this thread
        toExclusive = new PositionDescriptor(populations.length - 1, populations[populations.length-1].getIndividuals().length);
        new EvaluatorThread(this.barrier, function, populations, from, toExclusive).run(); // except of join we rather compute
    }

    public  ParallelFunctionEvaluator();
    public  ParallelFunctionEvaluator(int numThreads);

}