java.util.concurrent.ScheduledThreadPoolExecutor.canRunInCurrentRunState()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(73)

本文整理了Java中java.util.concurrent.ScheduledThreadPoolExecutor.canRunInCurrentRunState()方法的一些代码示例,展示了ScheduledThreadPoolExecutor.canRunInCurrentRunState()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ScheduledThreadPoolExecutor.canRunInCurrentRunState()方法的具体详情如下:
包路径:java.util.concurrent.ScheduledThreadPoolExecutor
类名称:ScheduledThreadPoolExecutor
方法名:canRunInCurrentRunState

ScheduledThreadPoolExecutor.canRunInCurrentRunState介绍

[英]Returns true if can run a task given current run state and run-after-shutdown parameters.
[中]如果给定当前运行状态和关机后运行参数,则返回true。

代码示例

代码示例来源:origin: robovm/robovm

/**
 * 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();
  }
}

代码示例来源:origin: robovm/robovm

/**
   * Overrides FutureTask version so as to reset/requeue if periodic.
   */
  public void run() {
    boolean periodic = isPeriodic();
    if (!canRunInCurrentRunState(periodic))
      cancel(false);
    else if (!periodic)
      ScheduledFutureTask.super.run();
    else if (ScheduledFutureTask.super.runAndReset()) {
      setNextRunTime();
      reExecutePeriodic(outerTask);
    }
  }
}

代码示例来源:origin: robovm/robovm

/**
 * 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();
  }
}

代码示例来源:origin: ibinti/bugvm

/**
 * 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();
  }
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * 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();
  }
}

代码示例来源:origin: MobiVM/robovm

/**
 * 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();
  }
}

代码示例来源:origin: jtulach/bck2brwsr

/**
 * 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
      prestartCoreThread();
  }
}

代码示例来源:origin: org.codehaus.jsr166-mirror/jsr166

/**
 * 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
      prestartCoreThread();
  }
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * 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();
  }
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * 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();
  }
}

代码示例来源:origin: org.apidesign.bck2brwsr/emul

/**
 * 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
      prestartCoreThread();
  }
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
   * Overrides FutureTask version so as to reset/requeue if periodic.
   */
  public void run() {
    boolean periodic = isPeriodic();
    if (!canRunInCurrentRunState(periodic))
      cancel(false);
    else if (!periodic)
      ScheduledFutureTask.super.run();
    else if (ScheduledFutureTask.super.runAndReset()) {
      setNextRunTime();
      reExecutePeriodic(outerTask);
    }
  }
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
   * Overrides FutureTask version so as to reset/requeue if periodic.
   */
  public void run() {
    boolean periodic = isPeriodic();
    if (!canRunInCurrentRunState(periodic))
      cancel(false);
    else if (!periodic)
      ScheduledFutureTask.super.run();
    else if (ScheduledFutureTask.super.runAndReset()) {
      setNextRunTime();
      reExecutePeriodic(outerTask);
    }
  }
}

代码示例来源:origin: MobiVM/robovm

/**
   * Overrides FutureTask version so as to reset/requeue if periodic.
   */
  public void run() {
    boolean periodic = isPeriodic();
    if (!canRunInCurrentRunState(periodic))
      cancel(false);
    else if (!periodic)
      ScheduledFutureTask.super.run();
    else if (ScheduledFutureTask.super.runAndReset()) {
      setNextRunTime();
      reExecutePeriodic(outerTask);
    }
  }
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
   * Overrides FutureTask version so as to reset/requeue if periodic.
   */
  public void run() {
    boolean periodic = isPeriodic();
    if (!canRunInCurrentRunState(periodic))
      cancel(false);
    else if (!periodic)
      ScheduledFutureTask.super.run();
    else if (ScheduledFutureTask.super.runAndReset()) {
      setNextRunTime();
      reExecutePeriodic(outerTask);
    }
  }
}

代码示例来源:origin: org.apidesign.bck2brwsr/emul

/**
   * Overrides FutureTask version so as to reset/requeue if periodic.
   */
  public void run() {
    boolean periodic = isPeriodic();
    if (!canRunInCurrentRunState(periodic))
      cancel(false);
    else if (!periodic)
      ScheduledFutureTask.super.run();
    else if (ScheduledFutureTask.super.runAndReset()) {
      setNextRunTime();
      reExecutePeriodic(outerTask);
    }
  }
}

代码示例来源:origin: ibinti/bugvm

/**
   * Overrides FutureTask version so as to reset/requeue if periodic.
   */
  public void run() {
    boolean periodic = isPeriodic();
    if (!canRunInCurrentRunState(periodic))
      cancel(false);
    else if (!periodic)
      ScheduledFutureTask.super.run();
    else if (ScheduledFutureTask.super.runAndReset()) {
      setNextRunTime();
      reExecutePeriodic(outerTask);
    }
  }
}

代码示例来源:origin: org.codehaus.jsr166-mirror/jsr166

/**
   * Overrides FutureTask version so as to reset/requeue if periodic.
   */
  public void run() {
    boolean periodic = isPeriodic();
    if (!canRunInCurrentRunState(periodic))
      cancel(false);
    else if (!periodic)
      ScheduledFutureTask.super.run();
    else if (ScheduledFutureTask.super.runAndReset()) {
      setNextRunTime();
      reExecutePeriodic(outerTask);
    }
  }
}

代码示例来源:origin: jtulach/bck2brwsr

/**
   * Overrides FutureTask version so as to reset/requeue if periodic.
   */
  public void run() {
    boolean periodic = isPeriodic();
    if (!canRunInCurrentRunState(periodic))
      cancel(false);
    else if (!periodic)
      ScheduledFutureTask.super.run();
    else if (ScheduledFutureTask.super.runAndReset()) {
      setNextRunTime();
      reExecutePeriodic(outerTask);
    }
  }
}

代码示例来源:origin: FlexoVM/flexovm

/**
   * Overrides FutureTask version so as to reset/requeue if periodic.
   */
  public void run() {
    boolean periodic = isPeriodic();
    if (!canRunInCurrentRunState(periodic))
      cancel(false);
    else if (!periodic)
      ScheduledFutureTask.super.run();
    else if (ScheduledFutureTask.super.runAndReset()) {
      setNextRunTime();
      reExecutePeriodic(outerTask);
    }
  }
}

相关文章

微信公众号

最新文章

更多

ScheduledThreadPoolExecutor类方法