Steady Framerate: Timer vs. Thread

Hey all! Alright, well i belive that the title of this describes what i'm basically looking for. Anyway, i'm writing a simple skateboarding game, and i need a steady framerate. I've tried multiple ways of keeping a steady framerate... all of which failed (obviously) which is why i'm here! ^.^ So yeah, If i already have a thread in my main class would you suggest me making an inner-class that fires a refresh() then waiting a specified number of milliseconds. Or do suggest having a timer that fires a repaint() every certain number of milliseconds. Or maybe there's some sort of custom way to adjust the framerate on different computers, making some sort of custom timer. I appreciate all your inputs! Thanks!

[724 byte] By [PaRlOaGna] at [2007-11-27 8:48:45]
# 1

Normally it may be implemented with two threads. The first calculates the scene motion and the second renders and blits the scene to screen. If You are using pure AWT without Swing You need not use repaint. Instead You may render from every thread directly using aquired graphics context. And swing applications must render from event dispatching thread with a component's graphics context. In this case You must use repaint() (called periodically from timer or other thread).

throwablea at 2007-7-12 20:56:30 > top of Java-index,Other Topics,Java Game Development...
# 2
But if i'm using pure awt (which is what i'm doing) shouldn't i still use repaint()? so as to attain a steady frame rate? and wouldn't double buffering would be rendered useless using a Graphics context?Message was edited by: PaRlOaGn
PaRlOaGna at 2007-7-12 20:56:30 > top of Java-index,Other Topics,Java Game Development...
# 3
Give this article a good read. http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html
CaptainMorgan08a at 2007-7-12 20:56:30 > top of Java-index,Other Topics,Java Game Development...
# 4
Thanks for both of your responses. I just realized that i really don't need a Thread for the main part of my class; took it out, Voila! smooth as ever. Thanks for the article, i will be needing it fairly soon when i star the Swing part of my GUI. Cheers! ^.^
PaRlOaGna at 2007-7-12 20:56:30 > top of Java-index,Other Topics,Java Game Development...