/**
  * Requeues a periodic task unless current run state precludes it. Same idea as delayedExecute
  * except drops task rather than rejecting.
  *
  * @param task the task
  */
 void reExecutePeriodic(RunnableScheduledFuture<?> task) {
   if (canRunInCurrentRunState(true)) {
     super.getQueue().add(task);
     if (!canRunInCurrentRunState(true) && remove(task)) task.cancel(false);
     else ensurePrestart();
   }
 }
 /**
  * Main execution method for delayed or periodic tasks. If pool is shut down, rejects the task.
  * Otherwise adds task to queue and starts a thread, if necessary, to run it. (We cannot prestart
  * the thread to run the task because the task (probably) shouldn't be run yet,) If the pool is
  * shut down while the task is being added, cancel and remove it if required by state and
  * run-after-shutdown parameters.
  *
  * @param task the task
  */
 private void delayedExecute(RunnableScheduledFuture<?> task) {
   if (isShutdown()) reject(task);
   else {
     super.getQueue().add(task);
     if (isShutdown() && !canRunInCurrentRunState(task.isPeriodic()) && remove(task))
       task.cancel(false);
     else ensurePrestart();
   }
 }