Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  100% cpu usage  (Read 935 times)
0 Members and 2 Guests are viewing this topic.
Offline mc_java

JGO n00b
*

Posts: 5


Java games rock!


« on: 2004-12-25 18:37:24 »

hello, just wanted to know if bad coding will result in high cpu usage.

my game so far generates 100% cpu usage and all i have is a 20 by 20 map in a jscrollPane. it lags whenever it has to do sth...

so is it my code thats causing this or is it sth else?

Offline darkprophet

JGO Neuromancer
****

Posts: 1171


Go Go Gadget Arms


« Reply #1 on: 2004-12-26 07:27:43 »

depends on what ur doing..

are you calling Thread.yeild(), Thread.sleep(x), or just an infinite loop?

If ur calling Thread.sleep(x), then it must be something else, If your doing a straight loop, with no timing, then its the programs fault.

If your doing Thread.yeild(), what happens is that your thread moves away from the cpu, giving another thread a chance to come and do its own stuff, and when thats finished, your thread comes back. So in essence, Thread.yeild() is the best way to go. 100% CPU usage is not a bad thing at all!

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.062 seconds with 19 queries.