喜洲古镇

spring定时器小结【1】-TimeTask的实现

TestTimerTask.javapackage cn.joypen.spring.demo3;import java.util.TimerTask;/**TimerTask测试@author JOYPEN@email user.zhaopeng@qq.com@webSite htt://joypen.cn@time 2010-7-22 下午07:26:21 */public class TestTimerTask extends TimerTask { @Override public void run() { System.out.println("enter TimerTask !"); }}applicationContext.xml< ?xml version="1.0" encoding="UTF-8"?>< !DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "spring-beans.dtd" > class=&quot;cn.joypen.spring.demo3.TestTimerTask&quot;&gt; class=&quot;org.springframework.scheduling.timer.ScheduledTimerTask&quot;&gt; 5000 5000 class=&quot;org.springframework.scheduling.timer.TimerFactoryBean&quot;&gt;TestMain1.java public static void main(String[] args) { // ApplicationContext ctx = new // FileSystemXmlApplicationContext("applicationContext.xml"); ApplicationContext ctx = new FileSystemXmlApplicationContext("/src/applicationContext.xml"); }