[J2ME] Restarting a Timer

Started by
0 comments, last by _nomad_ 18 years, 8 months ago
When I'm recreating a timer, it hangs on the scheduleAtFixedRate() function. (modified) code snippets: This is my timertask (code snippet A):
public static TimerTask taskiPollRequest = new TimerTask() {
        public void run() {
            if (this.scheduledExecutionTime() < System.currentTimeMillis() + 500) {
               Dosomethinghere();
            }
        }
    };
I create my timer like this (code snippet B):
    if(myTimer == null) {
        myTimer = new Timer();
    }

    myTimer.scheduleAtFixedRate(
        taskiPollRequest, 0, 30*1000);
when I no longer need the timer, I call: myTimer.cancel; myTimer = null; then when I need it again, i call code snippet B again. but it hangs on scheduleAtFixedRate(). any ideas? please help. thanks.
Advertisement
got it to work. just called a "new TimerTask { blah blah}" within the scheduleAtFixedRate() function parameter...

This topic is closed to new replies.

Advertisement