class WorkerCounter implements Executor {

    public synchronized void afterPreviousWorkersFinished(ActorRef<WorkerListener> onFinished) {
        if (this.onFinished != null) {
            throw new IllegalStateException("a callback already exists; wait for the workers to finish before setting a new callback");
        }
        this.onFinished = onFinished;
        if (activeWorkers.get() == 0) {
            fireAllWorkersFinished();
        }
    }

    public  WorkerCounter(Executor realExecutor);

}