Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Resetting A Timer, With Another Timer

 
Greenhorn
Posts: 6
Windows XP Suse
  • 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?
 
Sheriff
Posts: 16036
266
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • 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
Windows XP Suse
  • 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: 16036
266
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • 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.
 
Mo-om! You're embarassing me! Can you just read a tiny ad like a normal person?
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic