标签:
在项目中需要不断的发送请求,我使用过Thread来实现
在sring.xml中配置,引入索要操作的类
<bean name="timedReminderStart" class="com.jms.system.timedReminder.processor.TimedReminderStart" scope="singleton" > </bean>
package com.jms.system.timedReminder.processor; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import com.zkdy.util.JdbcUtil; public class TimedReminderStart { static int runNum = 0; static Timer timer = new Timer(); public TimedReminderStart() { super(); runNum++; if (runNum > 1) { return; } TimedReminderTask task = new TimedReminderTask(); task.setId("111"); timer.schedule(task, 3000); } }
package com.jms.system.timedReminder.processor; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.sql.Timestamp; import java.util.TimerTask; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import airmonitor.airflownmservice._1.AirFlowNMService; import airmonitor.airflownmservice._1.AirFlowNMService_Service; import com.cn.frame.util.DateUtil; import com.cn.frame.util.StringUtil; import com.zkdy.util.JdbcUtil; /** * 定时提醒 * * @author Administrator * */ public class TimedReminderTask extends TimerTask { private String id; public String getId() { return id; } public void setId(String id) { this.id = id; } @Override public void run() { System.out.println("执行"+id); } }
标签:
原文地址:http://blog.csdn.net/zpryan/article/details/45533111