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

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

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

ScheduledThreadPoolExecutor.delayedExecute介绍

[英]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.
[中]延迟或周期性任务的主要执行方法。如果池关闭,则拒绝该任务。否则会将任务添加到队列中,并在必要时启动一个线程来运行它。(我们不能预先启动线程来运行任务,因为任务(可能)还不应该运行。)如果在添加任务时关闭了池,请根据状态和关机后运行参数取消并删除它(如果需要)。

代码示例

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 */
public ScheduledFuture<?> schedule(Runnable command,
                  long delay,
                  TimeUnit unit) {
  if (command == null || unit == null)
    throw new NullPointerException();
  RunnableScheduledFuture<?> t = decorateTask(command,
    new ScheduledFutureTask<Void>(command, null,
                   triggerTime(delay, unit)));
  delayedExecute(t);
  return t;
}

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 */
public <V> ScheduledFuture<V> schedule(Callable<V> callable,
                    long delay,
                    TimeUnit unit) {
  if (callable == null || unit == null)
    throw new NullPointerException();
  RunnableScheduledFuture<V> t = decorateTask(callable,
    new ScheduledFutureTask<V>(callable,
                  triggerTime(delay, unit)));
  delayedExecute(t);
  return t;
}

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 * @throws IllegalArgumentException   {@inheritDoc}
 */
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command,
                       long initialDelay,
                       long period,
                       TimeUnit unit) {
  if (command == null || unit == null)
    throw new NullPointerException();
  if (period <= 0)
    throw new IllegalArgumentException();
  ScheduledFutureTask<Void> sft =
    new ScheduledFutureTask<Void>(command,
                   null,
                   triggerTime(initialDelay, unit),
                   unit.toNanos(period));
  RunnableScheduledFuture<Void> t = decorateTask(command, sft);
  sft.outerTask = t;
  delayedExecute(t);
  return t;
}

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 * @throws IllegalArgumentException   {@inheritDoc}
 */
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command,
                         long initialDelay,
                         long delay,
                         TimeUnit unit) {
  if (command == null || unit == null)
    throw new NullPointerException();
  if (delay <= 0)
    throw new IllegalArgumentException();
  ScheduledFutureTask<Void> sft =
    new ScheduledFutureTask<Void>(command,
                   null,
                   triggerTime(initialDelay, unit),
                   unit.toNanos(-delay));
  RunnableScheduledFuture<Void> t = decorateTask(command, sft);
  sft.outerTask = t;
  delayedExecute(t);
  return t;
}

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 */
public <V> ScheduledFuture<V> schedule(Callable<V> callable,
                    long delay,
                    TimeUnit unit) {
  if (callable == null || unit == null)
    throw new NullPointerException();
  RunnableScheduledFuture<V> t = decorateTask(callable,
    new ScheduledFutureTask<V>(callable,
                  triggerTime(delay, unit)));
  delayedExecute(t);
  return t;
}

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 */
public ScheduledFuture<?> schedule(Runnable command,
                  long delay,
                  TimeUnit unit) {
  if (command == null || unit == null)
    throw new NullPointerException();
  RunnableScheduledFuture<?> t = decorateTask(command,
    new ScheduledFutureTask<Void>(command, null,
                   triggerTime(delay, unit)));
  delayedExecute(t);
  return t;
}

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 */
public ScheduledFuture<?> schedule(Runnable command,
                  long delay,
                  TimeUnit unit) {
  if (command == null || unit == null)
    throw new NullPointerException();
  RunnableScheduledFuture<?> t = decorateTask(command,
    new ScheduledFutureTask<Void>(command, null,
                   triggerTime(delay, unit)));
  delayedExecute(t);
  return t;
}

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 */
public ScheduledFuture<?> schedule(Runnable command,
                  long delay,
                  TimeUnit unit) {
  if (command == null || unit == null)
    throw new NullPointerException();
  RunnableScheduledFuture<?> t = decorateTask(command,
    new ScheduledFutureTask<Void>(command, null,
                   triggerTime(delay, unit)));
  delayedExecute(t);
  return t;
}

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 */
public <V> ScheduledFuture<V> schedule(Callable<V> callable,
                    long delay,
                    TimeUnit unit) {
  if (callable == null || unit == null)
    throw new NullPointerException();
  RunnableScheduledFuture<V> t = decorateTask(callable,
    new ScheduledFutureTask<V>(callable,
                  triggerTime(delay, unit)));
  delayedExecute(t);
  return t;
}

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 */
public <V> ScheduledFuture<V> schedule(Callable<V> callable,
                    long delay,
                    TimeUnit unit) {
  if (callable == null || unit == null)
    throw new NullPointerException();
  RunnableScheduledFuture<V> t = decorateTask(callable,
    new ScheduledFutureTask<V>(callable,
                  triggerTime(delay, unit)));
  delayedExecute(t);
  return t;
}

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 */
public <V> ScheduledFuture<V> schedule(Callable<V> callable,
                    long delay,
                    TimeUnit unit) {
  if (callable == null || unit == null)
    throw new NullPointerException();
  RunnableScheduledFuture<V> t = decorateTask(callable,
    new ScheduledFutureTask<V>(callable,
                  triggerTime(delay, unit)));
  delayedExecute(t);
  return t;
}

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 */
public ScheduledFuture<?> schedule(Runnable command,
                  long delay,
                  TimeUnit unit) {
  if (command == null || unit == null)
    throw new NullPointerException();
  RunnableScheduledFuture<?> t = decorateTask(command,
    new ScheduledFutureTask<Void>(command, null,
                   triggerTime(delay, unit)));
  delayedExecute(t);
  return t;
}

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 */
public ScheduledFuture<?> schedule(Runnable command,
                  long delay,
                  TimeUnit unit) {
  if (command == null || unit == null)
    throw new NullPointerException();
  RunnableScheduledFuture<?> t = decorateTask(command,
    new ScheduledFutureTask<Void>(command, null,
                   triggerTime(delay, unit)));
  delayedExecute(t);
  return t;
}

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 */
public <V> ScheduledFuture<V> schedule(Callable<V> callable,
                    long delay,
                    TimeUnit unit) {
  if (callable == null || unit == null)
    throw new NullPointerException();
  RunnableScheduledFuture<V> t = decorateTask(callable,
    new ScheduledFutureTask<V>(callable,
                  triggerTime(delay, unit)));
  delayedExecute(t);
  return t;
}

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 */
public ScheduledFuture<?> schedule(Runnable command,
                  long delay,
                  TimeUnit unit) {
  if (command == null || unit == null)
    throw new NullPointerException();
  RunnableScheduledFuture<?> t = decorateTask(command,
    new ScheduledFutureTask<Void>(command, null,
                   triggerTime(delay, unit)));
  delayedExecute(t);
  return t;
}

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 */
public <V> ScheduledFuture<V> schedule(Callable<V> callable,
                    long delay,
                    TimeUnit unit) {
  if (callable == null || unit == null)
    throw new NullPointerException();
  RunnableScheduledFuture<V> t = decorateTask(callable,
    new ScheduledFutureTask<V>(callable,
                  triggerTime(delay, unit)));
  delayedExecute(t);
  return t;
}

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 */
public ScheduledFuture<?> schedule(Runnable command,
                  long delay,
                  TimeUnit unit) {
  if (command == null || unit == null)
    throw new NullPointerException();
  RunnableScheduledFuture<?> t = decorateTask(command,
    new ScheduledFutureTask<Void>(command, null,
                   triggerTime(delay, unit)));
  delayedExecute(t);
  return t;
}

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 */
public ScheduledFuture<?> schedule(Runnable command,
                  long delay,
                  TimeUnit unit) {
  if (command == null || unit == null)
    throw new NullPointerException();
  RunnableScheduledFuture<?> t = decorateTask(command,
    new ScheduledFutureTask<Void>(command, null,
                   triggerTime(delay, unit)));
  delayedExecute(t);
  return t;
}

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 */
public <V> ScheduledFuture<V> schedule(Callable<V> callable,
                    long delay,
                    TimeUnit unit) {
  if (callable == null || unit == null)
    throw new NullPointerException();
  RunnableScheduledFuture<V> t = decorateTask(callable,
    new ScheduledFutureTask<V>(callable,
                  triggerTime(delay, unit)));
  delayedExecute(t);
  return t;
}

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 */
public ScheduledFuture<?> schedule(Runnable command,
                  long delay,
                  TimeUnit unit) {
  if (command == null || unit == null)
    throw new NullPointerException();
  RunnableScheduledFuture<?> t = decorateTask(command,
    new ScheduledFutureTask<Void>(command, null,
                   triggerTime(delay, unit)));
  delayedExecute(t);
  return t;
}

相关文章

微信公众号

最新文章

更多

ScheduledThreadPoolExecutor类方法