code: 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);
          }
      }
docs: /*
  Waits until all submitted tasks are completed.