How to execute a repeated scheduled task
Article Metadata
If you want to create an repeated scheduled task every xxx milliseconds in Java ME you should use a TimerTask class, inserting the code in the run method.
import java.util.TimerTask;
public class MyTask extends TimerTask {
public void run() {
//Code to execute
}
}
Then, we should use this task in this way:
crono = new Timer();
task = new MyTask();
//Schedule every 1 second starting right now
crono.schedule(task, 0, 1000);


27 Sep
2009
Here is good example of executing any specific task number of times at particular interval is explained so nicely. To repeat the task j2me provides TimerTask class.Using the class's schedule method we can accomplish the said task.If you want to create an repeated scheduled task every xxx milliseconds in Java ME you should use a TimerTask class, inserting the code in the run method.
Must try and example.Can be useful at the time of authorization and while displaying some user targeted message.Well written and explained and code works fine.