• 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

Why does the run method in timertask executed twice

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I encountered a problem very similar described here :http://www.experts-exchange.com/Programming/Languages/Java/Q_22157484.html
I also tried the thread sleep method. It gets the same result.
 
Ranch Hand
Posts: 199
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lynnhom,Welcome to javaranch....
Things go unexpectedly wrong when you provide links in your posts casting your real problems in the problems and solutions described in those links instead of describing your original problem here at JavaRanch.... .
Try to google things but on javaranch describe your problems in your way rather than providing links here.
By the way your problem seem to be related to the tasks which should be executed at fixed intervals of time starting after specified amount of time.
Check the sample code given below-



For me this code prints "Hiiiii" after 50 seconds first time and then prints same after every 60 seconds.You can put your own business logic instead of System.out.println("hiiiii"); here.
Now tell me what you have done and what useful you have found in give code snippet.
 
Lynnhom Hsueh
Greenhorn
Posts: 2
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ankit, Thank you for your quick reply!
Let me describe my problem more specific: I want to make a Email auto sending function in my Red5 project. And I create a timer and schedule a timer task in the constructor of my Main Application class.
And I have found the reason now.
The constructor of Main Application has been executed twice.
Anyway, Thank you for your kindness again!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic