zoukankan      html  css  js  c++  java
  • springboot多线程实现邮件发送

    https://blog.csdn.net/github_39936816/article/details/80557977

    https://blog.csdn.net/lu_wei_wei/article/details/80242831

    @Configuration
    public class ThreadPoolConfig
    {
    //这些值也在配置文件配置
    // 核心线程池大小 private int corePoolSize = 50; // 最大可创建的线程数 private int maxPoolSize = 200; // 队列最大长度 private int queueCapacity = 1000; // 线程池维护线程所允许的空闲时间 private int keepAliveSeconds = 300; @Bean(name = "threadPoolTaskExecutor") public ThreadPoolTaskExecutor threadPoolTaskExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setMaxPoolSize(maxPoolSize); executor.setCorePoolSize(corePoolSize); executor.setQueueCapacity(queueCapacity); executor.setKeepAliveSeconds(keepAliveSeconds); // 线程池对拒绝任务(无线程可用)的处理策略 executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); return executor; } }

    调用

    
    
    @Autowired
    private ThreadPoolConfig threadPoolConfig;
    方法中调用----->
    threadPoolConfig.threadPoolTaskExecutor().execute(new Runnable() { @Override public void run() { try { String password = String.valueOf((int) ((Math.random() * 9 + 1) * 100000)); user.setSalt(ShiroUtils.randomSalt()); user.setPassword(passwordService.encryptPassword(loginName, password, user.getSalt())); if (userService.resetUserPwd(user) > 0) { String content = "********"; mailService.sendHtmlMail(user.getEmail(), "您的登录密码已经修改!", content); } } catch (Exception e) { System.out.println("邮件发送异常"); e.printStackTrace(); } } });

      

  • 相关阅读:
    第22章 Makefile基础
    第 36 章 TCP/IP协议基础
    socket通信
    移植zlib
    GNU Autotool介绍
    移植sqlite
    关于wireshark的使用
    关于UDP通信的参考目录
    线程问题
    大数据核心知识点:Hbase、Spark、Hive、MapReduce概念理解,特点及机制
  • 原文地址:https://www.cnblogs.com/person008/p/11463298.html
Copyright © 2011-2022 走看看