This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Creating Timer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Creating Timer" Watch "Creating Timer" New topic

Creating Timer

TesL lian

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

Joined: Mar 22, 2005
Posts: 41068
If Thread.sleep slows down the code, why do you have it in there?

Ping & DNS - my free Android networking tools app
TesL lian

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

Joined: Oct 27, 2005
Posts: 19651

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.

How To Ask Questions How To Answer Questions
Daesung Park
Ranch Hand

Joined: Mar 22, 2007
Posts: 68
Take a look at,%20long,%20long,%20java.util.concurrent.TimeUnit) and its implementing classes.

Daesung Park

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 37939
Sounds like a Swing-related question which I ought to move.
TesL lian

Joined: Feb 27, 2009
Posts: 4
Solved. Thanks all for your help.
subject: Creating Timer
Similar Threads
Timer & TimerTask - Name of Timer Object
Problem while translating Mesh(JSR 184)
How do I refresh the system time
How do i refresh theSystem Time
Problem while translating Mesh(JSR 184)