Merge pull request #529 from mabaiwan/develop

remove extra spaces
pull/531/head
小马哥 2 years ago committed by GitHub
commit d9738b6600
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

@ -45,13 +45,11 @@ public class TaskQueue<R extends Runnable> extends LinkedBlockingQueue<Runnable>
if (executor.getSubmittedTaskCount() < currentPoolThreadSize) {
return super.offer(runnable);
}
// 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.
if (currentPoolThreadSize < executor.getMaximumPoolSize()) {
return false;
}
// 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);
}

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

Loading…
Cancel
Save