Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

How to execute a repeated scheduled task

From Wiki
Jump to: navigation, search
Article Metadata
Created: firt (15 Apr 2007)
Last edited: hamishwillee (22 Jul 2013)

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);
This page was last modified on 22 July 2013, at 23:43.
54 page views in the last 30 days.