100% cpu usage

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?

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!