private boolean takeTask(){
  int size=tasks.size();
  for (int i=firstPending; i < size; i++) {
    Task t=tasks.get(i);
    if (!runAfter(t,i)) {
      if (i > firstPending) {
        tasks.remove(i);
        tasks.add(firstPending,t);
      }
      firstPending++;
      task=t;
      return true;
    }
  }
  return false;
}

private boolean takeTask ( ) { int size = tasks . size ( ) ; for ( int i = firstPending ; i < size ; i ++ ) { Task t = tasks . get ( i ) ; if ( ! runAfter ( t , i ) ) { if ( i > firstPending ) { tasks . remove ( i ) ; tasks . add ( firstPending , t ) ; } firstPending ++ ; task = t ; return true ; } } return false ; }
find the next task that can be run , and mark it taken by moving firstpending past it ( and moving the task in front of any pending tasks that are skipped due to execution constraints ) . if a task is found , set task to it and return true .
