Spring boot 生成线程池
作者:
金刚_30bf | 来源:发表于
2018-10-26 14:37 被阅读0次@Configuration
public class ConvertThreadPoolConfig {
private static final AtomicInteger threadIndex = new AtomicInteger(0);
@Bean(value = "convertThreadPool")
public ExecutorService convertThreadPool() {
ThreadFactory threadFactory = new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
Thread thread = new Thread(r, "convert-thread-" + threadIndex.incrementAndGet());
thread.setDaemon(true);
return thread;
}
};
ExecutorService pool = new ThreadPoolExecutor(2, 4, 0L, TimeUnit.MILLISECONDS,
new ArrayBlockingQueue<Runnable>(10), threadFactory, new ThreadPoolExecutor.CallerRunsPolicy());
return pool;
}
}
本文标题:Spring boot 生成线程池
本文链接:https://www.haomeiwen.com/subject/wznktqtx.html
网友评论