Spring + JDK Timer scheduler example

Note Learn the JDK Timer scheduler example without Spring and compare the different with this example. In this example, you will use Spring’s Scheduler API to schedule a task. 1. Scheduler Task Create a scheduler task… package com.mkyong.common; public class RunMeTask { public void printMe() { System.out.println("Run Me ~"); } } <bean id="runMeTask" class="com.mkyong.common.RunMeTask" /> …

Read more

JDK Timer scheduler example

JDK Timer is a simple scheduler for a specified task for repeated fixed-delay execution. To use this, you have to extends the TimerTask abstract class, override the run() method with your scheduler function. RunMeTask.java package com.mkyong.common; import java.util.TimerTask; public class RunMeTask extends TimerTask { @Override public void run() { System.out.println("Run Me ~"); } } Now, …

Read more