日期:2014-05-17 浏览次数:20956 次
public class MessageUtils extends Thread{
private boolean flag = true;
public void run() {
while (this.flag) {
try {
Thread.sleep(300000L); //5分钟
} catch (InterruptedException e1) {
e1.printStackTrace();
}
while (true) {
autoValidator();
try {
Thread.sleep(300000L);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
//靠线程每5分钟运行提交一次
public void autoValidator(){
//…………
if(condition1){
sendMessage(id,type);
}
else if(condition2){
sendMessage(id,type);
}
//…………
}
//手动提交
public static int sendMessage(String companyid, String type){
int result = 0;
//…………
return result;
}
}