SpringBoot中线程池的使用
项目启动后加载预处理数据
@Component
public class DataInit implements ApplicationRunner {
@Autowired
private UserMapper userMapper;
@Autowired
private RedisTemplate redisTemplate;
private ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("thread-call-runner-%d").build();
/**
* 避免使用Executors.newCachedThreadPool() / Executors.XXXXXXX
* 的方式,避免内存溢出
*
*/
private ExecutorService taskExe = new ThreadPoolExecutor(10, 20,
0L, TimeUnit.MIL
共有 0 条评论