When programming animations and little games I\'ve come to know the incredible importance of Thread.sleep(n);
I rely on this method to tell the operating system
Thread.sleep
is inaccurate and makes the animation jittery most of the time.
If you replace it completely with Thread.yield
you'll get a solid FPS without lag or jitter, however the CPU usage increases greatly. I moved to Thread.yield a long time ago.
This problem has been discussed on Java Game Development forums for years.