首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 其他相关 >

Spring 线程池运用2

2013-04-26 
Spring 线程池使用2!-- 设置最大池子的大小 ?--?property namemaxPoolSize value30/property

Spring 线程池使用2

<!-- 设置最大池子的大小 ?-->?

<property name="maxPoolSize" value="30"></property>

</bean>

?

?

public void sendFindPasswordMail(final UserT user,final String password) throws MessagingException, IOException, TemplateException {

?

this.getTaskExecutor().execute(new Runnable() {

? ? ? ?String emailcontent = " 尊敬的会员 ?" + user.getUsername() +" 您好,您的重置密码是 "+ password;

?public void run() {?

InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("email.properties");

Properties p = new Properties();

try {

p.load(inputStream);

} catch (IOException e1) {

e1.printStackTrace();

}

ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");

JavaMailSender sender = (JavaMailSender) ctx.getBean("javamailsenderimpl");

MimeMessage msg = sender.createMimeMessage();

MimeMessageHelper helper = null;

try {

helper = new MimeMessageHelper(msg, false, "UTF-8");

} catch (MessagingException e1) {

e1.printStackTrace();

}

try {

helper.setTo(user.getEmail());

helper.setFrom(p.getProperty("email.username"));

helper.setSubject("中付通会员找回密码邮件");

helper.setText("", true);

} catch (MessagingException e) {

e.printStackTrace();

}

sender.send(msg);

?

}

});

?

}

?

private TaskExecutor taskExecutor;

?

?

@JSON(serialize = false)

public TaskExecutor getTaskExecutor() {

return taskExecutor;

}

?

public void setTaskExecutor(TaskExecutor taskExecutor) {

this.taskExecutor = taskExecutor;

}

热点排行