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

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     }

 

posted @ 2016-07-07 14:57  代码工作者  阅读(538)  评论(0编辑  收藏  举报