<beans>
<bean id="timer" class="org.springframework.scheduling.timer.TimerFactoryBean">
<property name="scheduledTimerTasks">
<list>
<ref local="testtimertask"/>
</list>
</property>
</bean>
<bean id="timerbean" class="MyTimerImpl">
</bean>
<bean id="testtimertask" class="org.springframework.scheduling.timer.ScheduledTimerTask">
<property name="timerTask">
<ref bean="timerbean" />
</property>
<property name="delay">
<value>1000</value>
</property>
<property name="period">
<value>1000</value>
</property>
</bean>
</beans>
MyTimerImpl
import java.util.TimerTask;
public class MyTimerImpl extends TimerTask {
public void run() {
System.out.println("aaaaaaaa");
}
TestTimer
import net.loocky.sowq.util.ServiceFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
public class TestTimer {
/**
* @param args
*/
public static void main(String[] args) throws Exception {
ApplicationContext ctx=new FileSystemXmlApplicationContext("E:\\work\\Test\\bin\\spring-config.xml");
Thread.sleep(100000);
}
}
}
posted on 2006-05-25 17:59
小小程序程序员混口饭吃 阅读(1694)
评论(2) 编辑 收藏 所属分类:
java