private Set<Location> waitForTasksCompleted() {
        try {
            Set<Location> targets = new HashSet<>();
            FutureTask<Set<Location>> task;
            while ((task = tasks.poll()) != null) {
                // wait for completion
                if (!task.isDone())
                    targets.addAll(task.get());
            }
            return targets;
        } catch (InterruptedException|ExecutionException e) {
            throw new Error(e);
        }
    }
private Set < Location > waitForTasksCompleted ( ) { try { Set < Location > targets = new HashSet < > ( ) ; FutureTask < Set < Location > > task ; while ( ( task = tasks . poll ( ) ) != null ) { if ( ! task . isDone ( ) ) targets . addAll ( task . get ( ) ) ; } return targets ; } catch ( InterruptedException | ExecutionException e ) { throw new Error ( e ) ; } }
/*
Waits until all submitted tasks are completed.