-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
55 additions
and
175 deletions.
There are no files selected for viewing
62 changes: 0 additions & 62 deletions
62
eladmin-system/src/main/java/me/zhengjie/config/thread/AsyncTaskExecutePool.java
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
eladmin-system/src/main/java/me/zhengjie/config/thread/CustomExecutorConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package me.zhengjie.config.thread; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Primary; | ||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
import java.util.concurrent.Executor; | ||
import java.util.concurrent.ThreadPoolExecutor; | ||
|
||
/** | ||
* 创建自定义的线程池 | ||
* @author Zheng Jie | ||
* @description | ||
* @date 2023-06-08 | ||
**/ | ||
@Configuration | ||
public class CustomExecutorConfig { | ||
|
||
/** | ||
* 自定义线程池,用法 @Async | ||
* @return Executor | ||
*/ | ||
@Bean | ||
@Primary | ||
public Executor elAsync() { | ||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); | ||
executor.setCorePoolSize(AsyncTaskProperties.corePoolSize); | ||
executor.setMaxPoolSize(AsyncTaskProperties.maxPoolSize); | ||
executor.setQueueCapacity(AsyncTaskProperties.queueCapacity); | ||
executor.setThreadNamePrefix("el-async-"); | ||
executor.setKeepAliveSeconds(AsyncTaskProperties.keepAliveSeconds); | ||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); | ||
executor.initialize(); | ||
return executor; | ||
} | ||
|
||
/** | ||
* 自定义线程池,用法 @Async("otherAsync") | ||
* @return Executor | ||
*/ | ||
@Bean | ||
public Executor otherAsync() { | ||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); | ||
executor.setCorePoolSize(15); | ||
executor.setQueueCapacity(50); | ||
executor.setKeepAliveSeconds(AsyncTaskProperties.keepAliveSeconds); | ||
executor.setThreadNamePrefix("el-task-"); | ||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); | ||
executor.initialize(); | ||
return executor; | ||
} | ||
} |
64 changes: 0 additions & 64 deletions
64
eladmin-system/src/main/java/me/zhengjie/config/thread/TheadFactoryName.java
This file was deleted.
Oops, something went wrong.
46 changes: 0 additions & 46 deletions
46
eladmin-system/src/main/java/me/zhengjie/config/thread/ThreadPoolExecutorUtil.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters