zoukankan      html  css  js  c++  java
  • 创建线程池

    * 创建线程池对象

    @Bean
    public ThreadPoolTaskExecutor getThreadPool() {

    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();

    executor.setCorePoolSize(4);

    executor.setMaxPoolSize(8);

    executor.setQueueCapacity(100);

    executor.setKeepAliveSeconds(60);

    executor.setThreadNamePrefix("Pool-A");

    executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());

    executor.initialize();

    return executor;

    }
    ```

    * 使用线程池

    @Autowired
    private ThreadPoolTaskExecutor executorService;

    executorService.submit(new Runnable() {
    @Override
    public void run() {
    try {
    SendResult sendResult = sendMessage(topic, tag, finalTradePay.getPayId(), JSON.toJSONString(finalTradePay));
    log.info(JSON.toJSONString(sendResult));
    if (SendStatus.SEND_OK.equals(sendResult.getSendStatus())) {
    mqProducerTempMapper.deleteByPrimaryKey(mqProducerTemp.getId());
    System.out.println("删除消息表成功");
    }
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    });

  • 相关阅读:
    第八节 JS运动基础
    第七节 DOM操作应用-高级
    第六节 DOM操作应用
    第五讲 DOM基础
    第二节 数学基础与语言学基础
    第一节 自然语言处理概论
    第0节 课程简述
    第四节 定时器
    基本概念
    常用命令
  • 原文地址:https://www.cnblogs.com/hwgok/p/13956151.html
Copyright © 2011-2022 走看看