本文整理了Java中java.util.concurrent.ThreadPoolExecutor.getActiveCount()
方法的一些代码示例,展示了ThreadPoolExecutor.getActiveCount()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ThreadPoolExecutor.getActiveCount()
方法的具体详情如下:
包路径:java.util.concurrent.ThreadPoolExecutor
类名称:ThreadPoolExecutor
方法名:getActiveCount
[英]Returns the approximate number of threads that are actively executing tasks.
[中]返回正在积极执行任务的线程的大致数量。
代码示例来源:origin: spring-projects/spring-framework
/**
* Return the number of currently active threads.
* @see java.util.concurrent.ThreadPoolExecutor#getActiveCount()
*/
public int getActiveCount() {
if (this.threadPoolExecutor == null) {
// Not initialized yet: assume no active threads.
return 0;
}
return this.threadPoolExecutor.getActiveCount();
}
代码示例来源:origin: org.springframework/spring-context
/**
* Return the number of currently active threads.
* @see java.util.concurrent.ThreadPoolExecutor#getActiveCount()
*/
public int getActiveCount() {
if (this.threadPoolExecutor == null) {
// Not initialized yet: assume no active threads.
return 0;
}
return this.threadPoolExecutor.getActiveCount();
}
代码示例来源:origin: elasticjob/elastic-job-lite
/**
* 获取当前活跃的线程数.
*
* @return 当前活跃的线程数
*/
public int getActiveThreadCount() {
return threadPoolExecutor.getActiveCount();
}
代码示例来源:origin: PipelineAI/pipeline
/**
* Value from {@link ThreadPoolExecutor#getActiveCount()}
*
* @return Number
*/
public Number getCurrentActiveCount() {
return threadPool.getActiveCount();
}
代码示例来源:origin: alipay/sofa-rpc
@Override
public Integer value() {
return threadPoolExecutor.getActiveCount();
}
});
代码示例来源:origin: alipay/sofa-rpc
@Override
public Integer value() {
return threadPoolExecutor.getPoolSize() - threadPoolExecutor.getActiveCount();
}
});
代码示例来源:origin: alipay/sofa-rpc
@Override
public Integer value() {
return threadPoolExecutor.getPoolSize() - threadPoolExecutor.getActiveCount();
}
});
代码示例来源:origin: mpusher/mpush
public static Map<String, Object> getPoolInfo(ThreadPoolExecutor executor) {
Map<String, Object> info = new HashMap<>(5);
info.put("corePoolSize", executor.getCorePoolSize());
info.put("maxPoolSize", executor.getMaximumPoolSize());
info.put("activeCount(workingThread)", executor.getActiveCount());
info.put("poolSize(workThread)", executor.getPoolSize());
info.put("queueSize(blockedTask)", executor.getQueue().size());
return info;
}
代码示例来源:origin: voldemort/voldemort
@JmxGetter(name = "ActiveStorageThreads", description = "The number of active Storage worker threads.")
public int getActiveThreadsInWorkerPool() {
if(this.threadPoolExecutor != null) {
return this.threadPoolExecutor.getActiveCount();
} else {
return -1;
}
}
代码示例来源:origin: stanfordnlp/CoreNLP
/**
* Return status information about the underlying threadpool.
*/
@Override
public String toString() {
return String.format("active: %d/%d submitted: %d completed: %d input_q: %d output_q: %d idle_q: %d",
threadPool.getActiveCount(),
threadPool.getPoolSize(),
threadPool.getTaskCount(),
threadPool.getCompletedTaskCount(),
threadPool.getQueue().size(),
outputQueue.size(),
idleProcessors.size());
}
代码示例来源:origin: apache/incubator-dubbo
boolean ok = tp.getActiveCount() < tp.getMaximumPoolSize() - 1;
Status.Level lvl = Status.Level.OK;
if (!ok) {
+ ", core:" + tp.getCorePoolSize()
+ ", largest:" + tp.getLargestPoolSize()
+ ", active:" + tp.getActiveCount()
+ ", task:" + tp.getTaskCount()
+ ", service port: " + port);
代码示例来源:origin: apache/incubator-dubbo
boolean ok = tp.getActiveCount() < tp.getMaximumPoolSize() - 1;
Status.Level lvl = Status.Level.OK;
if (!ok) {
+ ", core:" + tp.getCorePoolSize()
+ ", largest:" + tp.getLargestPoolSize()
+ ", active:" + tp.getActiveCount()
+ ", task:" + tp.getTaskCount()
+ ", service port: " + port);
代码示例来源:origin: alipay/sofa-rpc
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
if (LOGGER.isWarnEnabled()) {
LOGGER.warn(LogCodes.getLog(LogCodes.ERROR_PROVIDER_TR_POOL_REJECTION, executor.getActiveCount(),
executor.getPoolSize(), executor.getLargestPoolSize(), executor
.getCorePoolSize(), executor.getMaximumPoolSize(), executor.getQueue()
.size(), executor.getQueue().remainingCapacity()));
}
throw new RejectedExecutionException();
}
}
代码示例来源: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: wildfly/wildfly
@ManagedAttribute(description="Current number of active threads in the thread pool")
public int getThreadPoolSizeActive() {
if(thread_pool instanceof ThreadPoolExecutor)
return ((ThreadPoolExecutor)thread_pool).getActiveCount();
if(thread_pool instanceof ForkJoinPool)
return ((ForkJoinPool)thread_pool).getRunningThreadCount();
return 0;
}
代码示例来源:origin: apache/hbase
@Override
protected Ratio getRatio() {
ThreadPoolExecutor batchPool = (ThreadPoolExecutor) conn.getCurrentBatchPool();
if (batchPool == null) {
return Ratio.of(0, 0);
}
return Ratio.of(batchPool.getActiveCount(), batchPool.getMaximumPoolSize());
}
});
代码示例来源:origin: apache/hbase
@Override
protected Ratio getRatio() {
ThreadPoolExecutor metaPool = (ThreadPoolExecutor) conn.getCurrentMetaLookupPool();
if (metaPool == null) {
return Ratio.of(0, 0);
}
return Ratio.of(metaPool.getActiveCount(), metaPool.getMaximumPoolSize());
}
});
代码示例来源:origin: weibocom/motan
private void rejectMessage(ChannelHandlerContext ctx, NettyMessage msg) {
if (msg.isRequest()) {
DefaultResponse response = new DefaultResponse();
response.setRequestId(msg.getRequestId());
response.setException(new MotanServiceException("process thread pool is full, reject by server: " + ctx.channel().localAddress(), MotanErrorMsgConstant.SERVICE_REJECT));
sendResponse(ctx, response);
LoggerUtil.error("process thread pool is full, reject, active={} poolSize={} corePoolSize={} maxPoolSize={} taskCount={} requestId={}",
threadPoolExecutor.getActiveCount(), threadPoolExecutor.getPoolSize(), threadPoolExecutor.getCorePoolSize(),
threadPoolExecutor.getMaximumPoolSize(), threadPoolExecutor.getTaskCount(), msg.getRequestId());
rejectCounter.incrementAndGet();
}
}
内容来源于网络,如有侵权,请联系作者删除!