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

  • 相关阅读:
    lightoj1140_数位dp
    lightoj1057_状压dp
    lightoj1068_数位dp
    lightoj1018_状压dp
    lightoj1217_简单dp
    lightoj1119_简单状压dp
    lightoj1037_状压dp
    lightoj1110_LCS并输出
    图论算法----最短路
    poj1182 食物链
  • 原文地址:https://www.cnblogs.com/hwgok/p/13956151.html
Copyright © 2011-2022 走看看