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);
            }
        });

  

posted @ 2023-06-12 14:09  章齐斌  阅读(9)  评论(0编辑  收藏  举报