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

  • 相关阅读:
    k3d安装k3s
    python自动目录环境
    http状态码
    linux下切换jdk版本
    pycharm py代码默认模板设置
    kubectl命令
    国内安装k3s
    minikube安装
    hmac-md5
    abstract class 与 interface
  • 原文地址:https://www.cnblogs.com/hwgok/p/13956151.html
Copyright © 2011-2022 走看看