多线程发送邮件和推送信息

1 new Thread(new MailThread(user,audit, status, remark,auditService)).start();
2                 //发送推送信息
3                 new Thread(new NoticeThread(user,audit, status, remark,auditService)).start();
 1 public class MailThread extends BaseAction implements Runnable {
 2     private User user;
 3     private Integer status;
 4     private String remark;
 5     
 6     private service service;
 7     
 8     
 9     public MailThread(User user, Audit audit, Integer status, String remark,Service service) {
10         super();
11         this.user = user;
12         this.audit = audit;
13         this.status = status;
14         this.remark = remark;
15         this.service = service;
16     }
17 
18     
19     public MailThread() {
20         super();
21     }
22 
23 
24     public Audit getAudit() {
25         return audit;
26     }
27 
28     public void setAudit(Audit audit) {
29         this.audit = audit;
30     }
31 
32     public int getStatus() {
33         return status;
34     }
35 
36     public void setStatus(int status) {
37         this.status = status;
38     }
39 
40     public String getRemark() {
41         return remark;
42     }
43 
44     public void setRemark(String remark) {
45         this.remark = remark;
46     }
47 
48     @Override
49     public void run() {
50         String message="";
51         Map<String,Object> map = new LinkedHashMap<String,Object>();
52         try{        
53             
54             if (MailUtil.sendMail(tobodys, "审核结果", message)) {
55                 message = "保存成功,邮件已经发送";
56     
57             } else {
58                 message = "保存成功,邮件发送失败";
59                 
60             }
61         }catch(Exception e){
62             message = "保存成功,邮件发送失败"+e.toString();
63             throw new MailSendException("发送失败");
64         }finally{
65             if("保存成功,邮件已经发送".equals(message)){
66                 map.put("sendstatus", "0");
67                 map.put("errormsg", "发送成功");
68             }else{
69                 map.put("sendstatus", "1");
70                 map.put("errormsg", "发送失                   败"+message.substring(1, 400));
71             }
72             
73             service.addLog(map);
74 
75         }
76 
77     }

 

转载于:https://www.cnblogs.com/doublekiller/p/5650132.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值