• Post Reply Bookmark Topic Watch Topic
  • New Topic

Resetting A Timer, With Another Timer  RSS feed

 
Herrington Argyle
Greenhorn
Posts: 6
Suse Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings. If you haven't noticed my post count yet, I'm new.

So I'm trying to manage a Timer that has a bunch of TimerTasks scheduled to it, and then lets them run free. However, it seems that the Timer needs to be updated, and the easiest way I figured to do that was scrap the old one and create a new one: complete with new TimerTasks. The hard part comes around when I try to use another Timer dedicated to destroying and rebuilding the main Timer. Here's the code, with the unimportant parts stripped out:

Here is the error it spits out at me:

So now onto my questions. I could either fix what causes this error (I haven't a clue as to how) or use another scheduling system to recreate the Timer. Which one would be easier, and where should I start?
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

java.util.TimerTask - public abstract void run() is the method you need to override. Your anonymous inner class has an overloaded run() because it has a Timer parameter.
 
Herrington Argyle
Greenhorn
Posts: 6
Suse Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ive never had to override anything before, therefore I don't exactly know how to go about doing that. What exactly would that look like?

As for anonymous classes, is there a way to provide them with parameters without causing any issue?
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Herrington Argyle wrote:What exactly would that look like?

Methods that override other methods look exactly like the methods they override. -- Try saying that three times

That is, they have the same method signature (name and parameters). I'm a little rusty on this stuff so somebody may have to step in to correct me but if I recall correctly, you can access variables in the block/class that surrounds an inner class but the variables have to be marked final which means the inner class can't change it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!