private void terminateTaskMgr(TaskManager taskMgr){
synchronized (taskMgr) {
    List pendingTasks=taskMgr.getPending();
    for (int i=0; i < pendingTasks.size(); i++) {
      taskMgr.remove((TaskManager.Task)pendingTasks.get(i));
    }
    taskMgr.terminate();
  }
}

private void terminateTaskMgr ( TaskManager taskMgr ) { synchronized ( taskMgr ) { List pendingTasks = taskMgr . getPending ( ) ; for ( int i = 0 ; i < pendingTasks . size ( ) ; i ++ ) { taskMgr . remove ( ( TaskManager . Task ) pendingTasks . get ( i ) ) ; } taskMgr . terminate ( ) ; } }
for the given taskmanager , this method removes all pending and active tasks .
