设计实现是要求在服务启动时,创建一批常驻线程,从阻塞队列里取元素执行业务逻辑。为此我刚开始使用的代码如下:
使用CommandLineRunner在服务启动时创建好线程
public class ConflictFactory implements CommandLineRunner{
private static final int CD_EXECUTOR_THREAD = Runtime.getRuntime().availableProcessors();
private static final ThreadPoolExecutor CD_EXECUTOR = new ThreadPoolExecutor(
CD_EXECUTOR_THREAD,
CD_EXECUTOR_THREAD,
0L,
TimeUnit<

最低0.47元/天 解锁文章
170万+

被折叠的 条评论
为什么被折叠?



