This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

fps is slowing down

 
Jochem Gruter
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My fps is slowing down. I begin at 60 fps and after 5 minutes it is 30 and after 15 minutes it is 5 fps.



My paint is in a jPanel and I've just painted some text and rects.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a Swing Timer, not Thread#sleep(...) for animation. And never never run an infinite loop or sleep on the EDT.

References:
http://download.oracle.com/javase/tutorial/uiswing/misc/timer.html
http://download.oracle.com/javase/tutorial/uiswing/concurrency/index.html
 
Rob Spoor
Sheriff
Pie
Posts: 20608
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, Thread.sleep(17) will sleep 17 milliseconds, not 17 seconds.
 
Stephan van Hulst
Bartender
Pie
Posts: 6106
72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
*scratches head*

It's not necessarily on the EDT right? And 17 ms seems like a decent amount to get around 60fps.

Anyway, I don't see why the OP is messing with thread priorities.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic