• Advertisement
Sign in to follow this  

[J2ME] Restarting a Timer

This topic is 4590 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
got it to work. just called a "new TimerTask { blah blah}" within the scheduleAtFixedRate() function parameter...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement