performing some code, every 5 seconds using system clock possibly??
Tim Tock
Greenhorn
Joined: Jan 15, 2004
Posts: 15
posted
0
Hi, Is it possible to have a java program perform some operation every x amount of seconds, something like{ (every 5 seconds) do{ system.out.println("I print out every 5 seconds"); } obviously the code inbetween the brackets is a little bit more complicated than that Thanks Timmy
Originally posted by Dirk Schreckmann: Also, note that a simple Thread.sleep(long millis) might do the trick well enough at times.
Note that this doesn't guarantee an exact amount of time that is paused. If the OS is busy doing something else when the time runs out, it may well keep doing what it is doing rather than restarting your program. I guess I shouldn't go too deep into this issue since it really isn't a beginner topic. I just thought I'd mention it. Layne
I think that's a good thing to point out. Just because we're beginners, doesn't mean it hurts us to learn some detail that might be good to know about a little bit down the line. So, please don't hesitate to mention the occasional detail, especially if it's important and might help to create an understanding of an issue.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: performing some code, every 5 seconds using system clock possibly??