Author
Creating Timer
TesL lian
Greenhorn
Joined: Feb 27, 2009
Posts: 4
How am i suppose to create a timer? i am looking for something to replace my Thread.sleep which seems to be slowing down my program.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35252
posted Mar 02, 2009 23:58:45
0
If Thread.sleep slows down the code, why do you have it in there?
Android apps – ImageJ plugins – Java web charts
TesL lian
Greenhorn
Joined: Feb 27, 2009
Posts: 4
i am looking for some sort of delays which does not affect my rendering loop. is there other recommendation? actually what i need is something more real-time then i can keep track of the different time for the different location.
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
In what thread do you do the rendering? Is this is Swing application, or something else?
In Swing, you can use javax.swing.Timer combined with an ActionListener .
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Daesung Park
Ranch Hand
Joined: Mar 22, 2007
Posts: 68
Take a look at http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ScheduledExecutorService.html#scheduleAtFixedRate(java.lang.Runnable,%20long,%20long,%20java.util.concurrent.TimeUnit) and its implementing classes.
Daesung Park
BLOG
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
Sounds like a Swing-related question which I ought to move.
TesL lian
Greenhorn
Joined: Feb 27, 2009
Posts: 4
Solved. Thanks all for your help.
subject: Creating Timer