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

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

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

ScheduledThreadPoolExecutor.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: 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: com.github.mcpat.libxjava/libxjava-jse5

public ScheduledTaskExecutor(int initialPoolSize, int maxPoolSize, long keepAliveTimeInMillis, IThreadFactory threadFactory) {
  _executorImpl= new ScheduledThreadPoolExecutorExtender(maxPoolSize, threadFactory);
  _executorImpl.setKeepAliveTime(keepAliveTimeInMillis, TimeUnit.MILLISECONDS);
  _executorImpl.allowCoreThreadTimeOut(true);
  
  for(int i= 0; i < initialPoolSize; i++) {
    _executorImpl.prestartCoreThread();
  }
}

代码示例来源: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: org.apidesign.bck2brwsr/emul

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

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

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

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

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

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

@Test
 public void idleScheduledThreadPoolExecutorTest() {
  ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1);
  profilingExecutor(stpe);
  stpe.prestartCoreThread();
  profiler.start();
  blockForProfilerSample();

  verifyDumpContains("ScheduledThreadPoolExecutor idle thread");
 }
}

相关文章

微信公众号

最新文章

更多

ScheduledThreadPoolExecutor类方法