Namespaces
Variants
Actions

How to execute a repeated scheduled task

Jump to: navigation, search
SignpostIcon Gear 52.png
Article Metadata

Article
Created: firt (15 Apr 2007)
Last edited: hamishwillee (11 Jan 2012)

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 11 January 2012, at 02:23.
98 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved