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

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

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

ScheduledThreadPoolExecutor.schedule介绍

暂无

代码示例

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

@Override
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
  return (ScheduledFuture<?>) super.schedule(command, delay, unit);
}

代码示例来源:origin: apache/incubator-druid

private Future<?> schedule(final T namespace)
{
 final long updateMs = namespace.getPollMs();
 Runnable command = new Runnable()
 {
  @Override
  public void run()
  {
   updateCache();
  }
 };
 if (updateMs > 0) {
  return cacheManager.scheduledExecutorService().scheduleAtFixedRate(command, 0, updateMs, TimeUnit.MILLISECONDS);
 } else {
  return cacheManager.scheduledExecutorService().schedule(command, 0, TimeUnit.MILLISECONDS);
 }
}

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

@Override
public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
  return (ScheduledFuture<V>) super.schedule(callable, delay, unit);
}

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

@Override
public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
  return (ScheduledFuture<V>) super.schedule(callable, delay, unit);
}

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

@Override
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
  return (ScheduledFuture<?>) super.schedule(command, delay, unit);
}

代码示例来源:origin: facebook/facebook-android-sdk

private static void onTimeSpentDataUpdate() {
    if (!hasChanges) {
      hasChanges = true;
      backgroundExecutor.schedule(
          appSessionInfoFlushRunnable,
          FLUSH_APP_SESSION_INFO_IN_SECONDS,
          TimeUnit.SECONDS);
    }
  }
}

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

@Override
public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
  return (ScheduledFuture<V>) super.schedule(callable, delay, unit);
}

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

@Override
public void execute(Runnable command) {
  super.schedule(new NonNotifyRunnable(command), 0, NANOSECONDS);
}

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

@Override
public void execute(Runnable command) {
  super.schedule(new NonNotifyRunnable(command), 0, NANOSECONDS);
}

代码示例来源:origin: koral--/android-gif-drawable

private void scheduleNextRender() {
  if (mIsRenderingTriggeredOnDraw && mIsRunning && mNextFrameRenderTime != Long.MIN_VALUE) {
    final long renderDelay = Math.max(0, mNextFrameRenderTime - SystemClock.uptimeMillis());
    mNextFrameRenderTime = Long.MIN_VALUE;
    mExecutor.remove(mRenderTask);
    mRenderTaskSchedule = mExecutor.schedule(mRenderTask, renderDelay, TimeUnit.MILLISECONDS);
  }
}

代码示例来源:origin: apache/hive

@Override
 public void run() {
  if (anyRow) {
   logThresholdInterval = Math.min(maxLogThresholdInterval, 2 * logThresholdInterval);
   logMemoryInfo();
  }
  memoryAndRowLogFuture =
    memoryAndRowLogExecutor.schedule(new MemoryInfoLogger(), logThresholdInterval, TimeUnit.MILLISECONDS);
 }
}

代码示例来源:origin: apache/rocketmq

public void putTask(String topic, Set<MessageQueue> mqNewSet) {
  Iterator<Entry<MessageQueue, PullTaskImpl>> it = this.taskTable.entrySet().iterator();
  while (it.hasNext()) {
    Entry<MessageQueue, PullTaskImpl> next = it.next();
    if (next.getKey().getTopic().equals(topic)) {
      if (!mqNewSet.contains(next.getKey())) {
        next.getValue().setCancelled(true);
        it.remove();
      }
    }
  }
  for (MessageQueue mq : mqNewSet) {
    if (!this.taskTable.containsKey(mq)) {
      PullTaskImpl command = new PullTaskImpl(mq);
      this.taskTable.put(mq, command);
      this.scheduledThreadPoolExecutor.schedule(command, 0, TimeUnit.MILLISECONDS);
    }
  }
}

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

public void schedule(String id, Runnable runnable, Date timeToRun) {
  ScheduledFuture<?> future = scheduler.schedule(runnable,
                          delayMs(timeToRun),
                          TimeUnit.MILLISECONDS);
  if(!allJobs.containsKey(id)) {
    allJobs.put(id, new ScheduledRunnable(runnable, timeToRun));
  }
  scheduledJobResults.put(id, future);
}

代码示例来源:origin: koral--/android-gif-drawable

void startAnimation(long lastFrameRemainder) {
  if (mIsRenderingTriggeredOnDraw) {
    mNextFrameRenderTime = 0;
    mInvalidationHandler.sendEmptyMessageAtTime(MSG_TYPE_INVALIDATION, 0);
  } else {
    cancelPendingRenderTask();
    mRenderTaskSchedule = mExecutor.schedule(mRenderTask, Math.max(lastFrameRemainder, 0), TimeUnit.MILLISECONDS);
  }
}

代码示例来源:origin: aws/aws-sdk-java

private ClientExecutionAbortTrackerTask scheduleTimerTask(int clientExecutionTimeoutMillis) {
  ClientExecutionAbortTask timerTask = new ClientExecutionAbortTaskImpl(Thread.currentThread());
  ScheduledFuture<?> timerTaskFuture = executor.schedule(timerTask, clientExecutionTimeoutMillis,
      TimeUnit.MILLISECONDS);
  return new ClientExecutionAbortTrackerTaskImpl(timerTask, timerTaskFuture);
}

代码示例来源:origin: facebook/facebook-android-sdk

private void schedulePoll() {
  scheduledPoll = DeviceAuthMethodHandler.getBackgroundExecutor().schedule(
      new Runnable() {
        @Override
        public void run() {
          poll();
        }
      },
      currentRequestState.getInterval(),
      TimeUnit.SECONDS);
}

代码示例来源:origin: alibaba/Sentinel

static void scheduleWriteTask(StatRollingData statRollingData) {
  if (statRollingData != null) {
    try {
      StatLogWriteTask task = new StatLogWriteTask(statRollingData);
      writerThreadPool.schedule(task, STAT_ENTRY_COOL_DOWN_MILLIS, TimeUnit.MILLISECONDS);
    } catch (Throwable t) {
      EagleEye.selfLog("[ERROR] fail to roll statLogger[" +
        statRollingData.getStatLogger().getLoggerName() + "]", t);
    }
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public Boolean call() throws Exception {
    pSpace.update(getPhysicsSpace().getAccuracy() * getSpeed());
    pSpace.distributeEvents();
    long update = System.currentTimeMillis() - detachedPhysicsLastUpdate;
    detachedPhysicsLastUpdate = System.currentTimeMillis();
    executor.schedule(detachedPhysicsUpdate, Math.round(getPhysicsSpace().getAccuracy() * 1000000.0f) - (update * 1000), TimeUnit.MICROSECONDS);
    return true;
  }
};

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public Boolean call() throws Exception {
    pSpace.update(getPhysicsSpace().getAccuracy() * getSpeed());
    pSpace.distributeEvents();
    long update = System.currentTimeMillis() - detachedPhysicsLastUpdate;
    detachedPhysicsLastUpdate = System.currentTimeMillis();
    executor.schedule(detachedPhysicsUpdate, Math.round(getPhysicsSpace().getAccuracy() * 1000000.0f) - (update * 1000), TimeUnit.MICROSECONDS);
    return true;
  }
};

代码示例来源:origin: lets-blade/blade

public static void main(String[] args) throws ParseException {
  ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(2);
  System.out.println("Hello World1");
  scheduledThreadPoolExecutor.schedule(() -> {
    System.out.println("Hello World2");
  }, 5000, TimeUnit.MILLISECONDS);
  scheduledThreadPoolExecutor.shutdown();
  CronExecutorService cronExecutorService = new CronThreadPoolExecutor(2, null);
  cronExecutorService.submit(new Task("task1", new CronExpression("* * * * ?"), 0L));
}

相关文章

微信公众号

最新文章

更多

ScheduledThreadPoolExecutor类方法