Java 线程池简单使用
private final ThreadPoolExecutor handleExecutor = new ThreadPoolExecutor( 3, 5, 5000L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), new ThreadFactoryBuilder().setNameFormat("MsgCenterHandle-%d").build());
handleExecutor.execute(() -> { try { if (res > 0) { // 添加未读数量 msgCenterService.addUnReadCount(msgTypeId, userIdList); } } catch (Exception e) { log.error("消息盒子: 消息入库异常. {}", e, e); } });