• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to write a Schedular class??  RSS feed

 
Sajee Joseph
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
I need to have a schedular which runs every 2 hours.
Currently i have achived this using the following code:

class MySchedular extends Thread
{
public void run()
{
while(true)
{
// My code goes here
this.sleep(1000*60*60*2);
}
}
}

Is there is a better means of achieving this?
Regards,
Sajee
 
Adrian Yan
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at the Timer class, I found very useful from time to time.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!