Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
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
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Beginning Java
Timer Problem
wayne whitman
Greenhorn
Posts: 10
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi All. I'm having a timer problem maybe someone can explain to me. In the following code, I am attempting to execute setRIPTrip() once every 2 seconds. What happens is it gets executed only once. What can be wrong here?
import java.util.*; public class RenewRip { java.util.Timer RIPTimer; public void RenewRip(int seconds) { RIPTimer = new java.util.Timer(); RIPTimer.schedule(new RunRip(),0,seconds*1000); } class RunRip extends TimerTask { public void run() { RIP r = new RIP(); r.setRIPTrip(); } } public static void main(String args[]) { RenewRip r = new RenewRip(); r.RenewRip(2); } } // calling code (from another class in a Swing worker thread) RenewRip r = new RenewRip(); r.RenewRip(2);
Thanks!
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
TimerTask and Schedule
Threads doubt
User Prompt Timer
Scheduling with Thread
Set Timer
More...