|
|
|
@ -11,7 +11,23 @@ public abstract class TaskBaseService implements TaskHandler {
|
|
|
|
|
protected int corePoolSiz = 4;
|
|
|
|
|
protected int maxPoolSize = 10;
|
|
|
|
|
protected int queueCapacity = 500;
|
|
|
|
|
protected String TaskExecutorName = "TaskPool";
|
|
|
|
|
protected String taskExecutorName = "TaskPool";
|
|
|
|
|
|
|
|
|
|
public int getCorePoolSiz() {
|
|
|
|
|
return corePoolSiz;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getMaxPoolSize() {
|
|
|
|
|
return maxPoolSize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getQueueCapacity() {
|
|
|
|
|
return queueCapacity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getTaskExecutorName() {
|
|
|
|
|
return taskExecutorName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Executor getAsyncExecutor() {
|
|
|
|
|
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
|
|
|
@ -19,7 +35,7 @@ public abstract class TaskBaseService implements TaskHandler {
|
|
|
|
|
executor.setCorePoolSize(corePoolSiz + 1);
|
|
|
|
|
executor.setMaxPoolSize(maxPoolSize);
|
|
|
|
|
executor.setQueueCapacity(queueCapacity);
|
|
|
|
|
executor.setThreadNamePrefix(TaskExecutorName);
|
|
|
|
|
executor.setThreadNamePrefix(taskExecutorName);
|
|
|
|
|
executor.initialize();
|
|
|
|
|
return executor;
|
|
|
|
|
}
|
|
|
|
@ -66,7 +82,7 @@ public abstract class TaskBaseService implements TaskHandler {
|
|
|
|
|
int poolSize = mTaskPool.getPoolSize();
|
|
|
|
|
int maxPoolSize = mTaskPool.getMaxPoolSize();
|
|
|
|
|
int queueSize = mTaskPool.getThreadPoolExecutor().getQueue().size();
|
|
|
|
|
return String.format("异步方法从线程:%s中被调用!TaskExecutor状态 - 活跃线程数:%d, 线程池大小:%d, 最大线程池大小:%d, 队列大小:%d",
|
|
|
|
|
return String.format("异步方法从线程:%s中被调用!状态 - 活跃线程数:%d, 线程池大小:%d, 最大线程池大小:%d, 队列大小:%d",
|
|
|
|
|
currentThreadName, activeThreads, poolSize, maxPoolSize, queueSize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|