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

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

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

ThreadPoolExecutor.isShutdown介绍

暂无

代码示例

代码示例来源:origin: elasticjob/elastic-job-lite

public boolean isShutdown() {
  return threadPoolExecutor.isShutdown();
}

代码示例来源:origin: igniterealtime/Openfire

/**
 * Returns true if the channel is currently running. The channel can be started and
 * stopped by calling the start() and stop() methods.
 *
 * @return true if the channel is running.
 */
public boolean isRunning() {
  return !executor.isShutdown();
}

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

@Override
public boolean isShutdown() {
  return executor.isShutdown();
}

代码示例来源:origin: ethereum/ethereumj

public boolean isShutdown() {
  return exec.isShutdown();
}

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

/**
   * Executes task r in the caller's thread, unless the executor
   * has been shut down, in which case the task is discarded.
   *
   * @param r the runnable task requested to be executed
   * @param e the executor attempting to execute this task
   */
  public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
    if (!e.isShutdown()) {
      r.run();
    }
  }
}

代码示例来源:origin: Justson/AgentWeb

private void internalInit() {
  if (mThreadPoolExecutor != null && !mThreadPoolExecutor.isShutdown()) {
    mThreadPoolExecutor.shutdownNow();
  }
  mThreadPoolExecutor = new ThreadPoolExecutor(
      CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE_SECONDS, TimeUnit.SECONDS,
      sPoolWorkQueue, sThreadFactory);
  mThreadPoolExecutor.allowCoreThreadTimeOut(true);
}

代码示例来源:origin: Netflix/Priam

public void rejectedExecution(Runnable task, ThreadPoolExecutor executor) {
    while (true) {
      if (executor.isShutdown())
        throw new RejectedExecutionException("ThreadPoolExecutor has shut down");
      try {
        if (queue.offer(task, 1000, TimeUnit.MILLISECONDS)) break;
      } catch (InterruptedException e) {
        // NOP
      }
    }
  }
}

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

public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {

    if(!executor.isShutdown()) {
      handler.rejectedExecution(r, executor);
    }
  }
}

代码示例来源:origin: qiujiayu/AutoLoadCache

@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
  if (!e.isShutdown()) {
    Runnable last = e.getQueue().poll();
    if (last instanceof RefreshTask) {
      RefreshTask lastTask = (RefreshTask) last;
      refreshing.remove(lastTask.getCacheKey());
    }
    e.execute(r);
  }
}

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

@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
  if (messageExecutor.isShutdown()) {
    return;
  }
  if (LOGGER.isInfoEnabled()) {
    LOGGER.info("channel inactive:" + ctx.channel());
  }
  releaseChannel(ctx.channel(), NetUtil.toStringAddress(ctx.channel().remoteAddress()));
  super.channelInactive(ctx);
}

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

@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
  if (messageExecutor.isShutdown()) {
    return;
  }
  if (LOGGER.isInfoEnabled()) {
    LOGGER.info("channel inactive:" + ctx.channel());
  }
  releaseChannel(ctx.channel(), NetUtil.toStringAddress(ctx.channel().remoteAddress()));
  super.channelInactive(ctx);
}

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

@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
  String msg = String.format("Thread pool is EXHAUSTED!" +
          " Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d)," +
          " Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s), in %s://%s:%d!",
      threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(), e.getLargestPoolSize(),
      e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(), e.isTerminating(),
      url.getProtocol(), url.getIp(), url.getPort());
  logger.warn(msg);
  dumpJStack();
  throw new RejectedExecutionException(msg);
}

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

@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
  String msg = String.format("Thread pool is EXHAUSTED!" +
          " Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d)," +
          " Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s), in %s://%s:%d!",
      threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(), e.getLargestPoolSize(),
      e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(), e.isTerminating(),
      url.getProtocol(), url.getIp(), url.getPort());
  logger.warn(msg);
  dumpJStack();
  throw new RejectedExecutionException(msg);
}

代码示例来源:origin: vipshop/vjtools

@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
  String msg = String.format(
      "Thread pool is EXHAUSTED!"
          + " Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d),"
          + " Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s)!",
      threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(),
      e.getLargestPoolSize(), e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(),
      e.isTerminating());
  logger.warn(msg);
  dummper.tryThreadDump(null);
  throw new RejectedExecutionException(msg);
}

代码示例来源:origin: mpusher/mpush

@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
  LOGGER.warn("one task rejected, poolConfig={}, poolInfo={}", poolConfig, Utils.getPoolInfo(e));
  if (!dumping) {
    dumping = true;
    dumpJVMInfo();
  }
  if (rejectedPolicy == REJECTED_POLICY_ABORT) {
    throw new RejectedExecutionException("one task rejected, pool=" + poolConfig.getName());
  } else if (rejectedPolicy == REJECTED_POLICY_CALLER_RUNS) {
    if (!e.isShutdown()) {
      r.run();
    }
  }
}

代码示例来源:origin: fengjiachun/Jupiter

@Override
  public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
    logger.error("Thread pool [{}] is exhausted! {}.", threadPoolName, e.toString());

    dumpJvmInfoIfNeeded();

    if (!e.isShutdown()) {
      try {
        e.getQueue().put(r);
      } catch (InterruptedException ignored) { /* should not be interrupted */ }
    }
  }
}

代码示例来源:origin: fengjiachun/Jupiter

@Override
  public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
    logger.error("Thread pool [{}] is exhausted! {}.", threadPoolName, e.toString());

    dumpJvmInfoIfNeeded();

    if (!e.isShutdown()) {
      try {
        e.getQueue().put(r);
      } catch (InterruptedException ignored) { /* should not be interrupted */ }
    }
  }
}

代码示例来源:origin: fengjiachun/Jupiter

@Override
  public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
    logger.error("Thread pool [{}] is exhausted! {}.", threadPoolName, e.toString());

    dumpJvmInfoIfNeeded();

    if (!e.isShutdown()) {
      r.run();
    }
  }
}

代码示例来源:origin: fengjiachun/Jupiter

@Override
  public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
    logger.error("Thread pool [{}] is exhausted! {}.", threadPoolName, e.toString());

    dumpJvmInfoIfNeeded();

    if (!e.isShutdown()) {
      r.run();
    }
  }
}

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

/**
 * Channel inactive.
 *
 * @param ctx the ctx
 * @throws Exception the exception
 */
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
  debugLog("inactive:" + ctx);
  if (messageExecutor.isShutdown()) {
    return;
  }
  handleDisconnect(ctx);
  super.channelInactive(ctx);
}

相关文章

ThreadPoolExecutor类方法