private void completeAllEffects() {

        if(pendingEffects.isEmpty())
            return;

        Collection<ForkJoinTask> receipts = new LinkedList<>();

        //submit all actions. For each agent they happen in sequence
        for(Map.Entry<Agent,Collection<Effect>> effects : pendingEffects.asMap().entrySet() )
        {
            List<Effect> todo =(List)effects.getValue(); //the cast is always correct because it's a MultiMapList
            final ForkJoinTask<?> receipt = threadPool.submit(() -> {
                Collections.sort(todo);
                for (Effect e : todo)
                    e.run();
            });
            receipts.add(receipt);
        }

        //now wait for all of them to complete
        try {
            for (ForkJoinTask receipt : receipts)
                receipt.get();
            pendingEffects.clear();

        }
        catch (Exception e){
            e.printStackTrace();
            System.err.println("interrupted");
            System.exit(-1);
        }
        //done



    }