Investigation of optimal sleep time calculation in game loop

前端 未结 5 616
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-08 08:47

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

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 09:02

    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.

提交回复
热议问题