Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,19 @@ public void setQueueCapacity(int queueCapacity) {
AsyncExecutor.queueCapacity = queueCapacity;
}

/**
* 定义自定义异步处理线程池,线程名的标号自增计数器
*/
private static AtomicInteger atomicInteger = new AtomicInteger(1);

/**
* 自定义线程池,用法 @Async
* @return Executor
*/
@Override
public Executor getAsyncExecutor() {
// 自定义工厂
ThreadFactory factory = r -> new Thread(r, "el-async-" + new AtomicInteger(1).getAndIncrement());
ThreadFactory factory = r -> new Thread(r, "el-async-" + atomicInteger.getAndIncrement());
// 自定义线程池
return new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveSeconds,
TimeUnit.SECONDS, new ArrayBlockingQueue<>(queueCapacity), factory,
Expand Down