Remove extra spaces

pull/529/head
chen.ma 2 years ago
parent 0806c4c8c6
commit 8f4dcda73e

@ -220,17 +220,11 @@ public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner
AlarmNotifyRequest request = new AlarmNotifyRequest(); AlarmNotifyRequest request = new AlarmNotifyRequest();
String appName = StrUtil.isBlank(itemId) ? applicationName : itemId; String appName = StrUtil.isBlank(itemId) ? applicationName : itemId;
request.setAppName(appName); request.setAppName(appName);
// 核心线程数
int corePoolSize = threadPoolExecutor.getCorePoolSize(); int corePoolSize = threadPoolExecutor.getCorePoolSize();
// 最大线程数
int maximumPoolSize = threadPoolExecutor.getMaximumPoolSize(); int maximumPoolSize = threadPoolExecutor.getMaximumPoolSize();
// 线程池当前线程数 (有锁)
int poolSize = threadPoolExecutor.getPoolSize(); int poolSize = threadPoolExecutor.getPoolSize();
// 活跃线程数 (有锁)
int activeCount = threadPoolExecutor.getActiveCount(); int activeCount = threadPoolExecutor.getActiveCount();
// 同时进入池中的最大线程数 (有锁)
int largestPoolSize = threadPoolExecutor.getLargestPoolSize(); int largestPoolSize = threadPoolExecutor.getLargestPoolSize();
// 线程池中执行任务总数量 (有锁)
long completedTaskCount = threadPoolExecutor.getCompletedTaskCount(); long completedTaskCount = threadPoolExecutor.getCompletedTaskCount();
request.setActive(active.toUpperCase()); request.setActive(active.toUpperCase());
request.setIdentify(IdentifyUtil.getIdentify()); request.setIdentify(IdentifyUtil.getIdentify());
@ -241,13 +235,9 @@ public class ThreadPoolNotifyAlarmHandler implements Runnable, CommandLineRunner
request.setLargestPoolSize(largestPoolSize); request.setLargestPoolSize(largestPoolSize);
request.setCompletedTaskCount(completedTaskCount); request.setCompletedTaskCount(completedTaskCount);
BlockingQueue<Runnable> queue = threadPoolExecutor.getQueue(); BlockingQueue<Runnable> queue = threadPoolExecutor.getQueue();
// 队列元素个数
int queueSize = queue.size(); int queueSize = queue.size();
// 队列类型
String queueType = queue.getClass().getSimpleName(); String queueType = queue.getClass().getSimpleName();
// 队列剩余容量
int remainingCapacity = queue.remainingCapacity(); int remainingCapacity = queue.remainingCapacity();
// 队列容量
int queueCapacity = queueSize + remainingCapacity; int queueCapacity = queueSize + remainingCapacity;
request.setQueueName(queueType); request.setQueueName(queueType);
request.setCapacity(queueCapacity); request.setCapacity(queueCapacity);

@ -45,13 +45,11 @@ public class TaskQueue<R extends Runnable> extends LinkedBlockingQueue<Runnable>
if (executor.getSubmittedTaskCount() < currentPoolThreadSize) { if (executor.getSubmittedTaskCount() < currentPoolThreadSize) {
return super.offer(runnable); return super.offer(runnable);
} }
// The current number of threads in the thread pool is less than the maximum number of threads, and returns false. // The current number of threads in the thread pool is less than the maximum number of threads, and returns false.
// According to the thread pool source code, non-core threads will be created. // According to the thread pool source code, non-core threads will be created.
if (currentPoolThreadSize < executor.getMaximumPoolSize()) { if (currentPoolThreadSize < executor.getMaximumPoolSize()) {
return false; return false;
} }
// If the current thread pool number is greater than the maximum number of threads, the task is added to the blocking queue. // If the current thread pool number is greater than the maximum number of threads, the task is added to the blocking queue.
return super.offer(runnable); return super.offer(runnable);
} }

@ -42,7 +42,7 @@ public class RegisterDynamicThreadPoolTest {
.maximumPoolSize(10) .maximumPoolSize(10)
.queueType(QueueTypeEnum.RESIZABLE_LINKED_BLOCKING_QUEUE.type) .queueType(QueueTypeEnum.RESIZABLE_LINKED_BLOCKING_QUEUE.type)
.capacity(110) .capacity(110)
// TimeUnit.SECONDS // TimeUnit.SECONDS
.keepAliveTime(100L) .keepAliveTime(100L)
// TimeUnit.MILLISECONDS // TimeUnit.MILLISECONDS
.executeTimeOut(800L) .executeTimeOut(800L)

Loading…
Cancel
Save