Jump to content
  • Advertisement
Sign in to follow this  
_nomad_

[J2ME] Restarting a Timer

This topic is 4764 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
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!