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

      

  • 相关阅读:
    HTTP-接触
    什么是虚拟机-粗略学习
    jQuery中的动画理论干货
    jQuery-中的事件
    熟悉又陌生的快捷方式
    jQuery中的DOM操作
    jQuery与javascript库
    jQuery-选择器(2)
    jest操作 Elasticsearch
    配置 Kibana
  • 原文地址:https://www.cnblogs.com/person008/p/11463307.html
Copyright © 2020-2023  润新知