protected void executeTasks(final AccessPathTask[] tasks) throws Exception {
  if (executor == null) {
    for (    AccessPathTask task : tasks) {
      task.call();
    }
    return;
  }
  final List<FutureTask<Void>> futureTasks=new LinkedList<FutureTask<Void>>();
  for (  AccessPathTask task : tasks) {
    final FutureTask<Void> ft=new FutureTaskMon<Void>(task);
    futureTasks.add(ft);
  }
  try {
    for (    FutureTask<Void> ft : futureTasks) {
      halted();
      executor.execute(ft);
    }
    for (    FutureTask<Void> ft : futureTasks) {
      if (!isDone())       ft.get();
    }
  }
  finally {
    for (    FutureTask<Void> ft : futureTasks) {
      ft.cancel(true);
    }
  }
}

protected void executeTasks ( final AccessPathTask [ ] tasks ) throws Exception { if ( executor == null ) { for ( AccessPathTask task : tasks ) { task . call ( ) ; } return ; } final List < FutureTask < Void > > futureTasks = new LinkedList < FutureTask < Void > > ( ) ; for ( AccessPathTask task : tasks ) { final FutureTask < Void > ft = new FutureTaskMon < Void > ( task ) ; futureTasks . add ( ft ) ; } try { for ( FutureTask < Void > ft : futureTasks ) { halted ( ) ; executor . execute ( ft ) ; } for ( FutureTask < Void > ft : futureTasks ) { if ( ! isDone ( ) ) ft . get ( ) ; } } finally { for ( FutureTask < Void > ft : futureTasks ) { ft . cancel ( true ) ; } } }
either execute the tasks in the caller ' s thread or schedule them for execution on the supplied service .
