aspose file tools
The moose likes Game Development and the fly likes basic question... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "basic question..." Watch "basic question..." New topic
Author

basic question...

Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
I decided to make a simple arcade game. In the main class I have a "while(true)" loop and inside of this loop it redraws the screens listens to keystrokes etc. I would assume this is fairly typical. I just want to know why when I run the game on one machine it uses almost 100% of the CPU and on another machine it only uses 50%. The only differences I can think of is one is an AMD and the other is a Pentium, both are running windows XP professional. Both machines are running Java 1.5. I haven't put anything into to regulate the fps, and am assuming this means it uses as much of the cpu as its being allowed too. On the first machine I do want to slow it down a bit, but on the second machine... I think I'd rather make it go a little faster. I'm guessing to slow it down I just need a timer and to have it only redraw the screen after X amount of time, as for speeding it up I have no clue where to start.
Kino Lobo
Greenhorn

Joined: Feb 08, 2006
Posts: 20
Hi!

You'd better provide a way for the main thread of the game have some sleep.
But I have no idea of how could you control the CPU's capacity usage...
By the way, if you figure out a way, please let us know, ok?


I'd rather trust a man who works with his hands!
Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
I figured making the thread sleep would be the best way to regulate the speed of the game.

I just don't understand (and I guess this isn't obvious and probably platform/jvm specific) why on one machine the jvm would take full control of the cpu and on another machine be throttled to only using 50% of the cpu. Especially when they're both the same OS and afaik same jre (1.5.06)
Brendan Caden
Greenhorn

Joined: Jan 09, 2006
Posts: 5
Is the machine that runs at 50% dual processor or dual core?
Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
No, one's an intel chip(p4 2.6ghz) and the other is an amd (XP 2900). On the intel chip I've never seen any java application use more than 50% of the processor (its like there is a limit), but not so on the amd machine. Both are running Windows XP sp2. Just seems odd to me.
Jeremy Tartaglia
Ranch Hand

Joined: Mar 11, 2004
Posts: 62
It's probably Hyper-Threading.
Guy Allard
Ranch Hand

Joined: Nov 24, 2000
Posts: 776
You sure?

On the command line if you:

set

What is the NUMBER_OF_PROCESSORS environment variable equal to? Same on both machines?

Guy
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24189
    
  34

Originally posted by Jeremy Tartaglia:
It's probably Hyper-Threading.


That's what I was thinking; in this case the 50% number is really meaningless -- it means 100%.


[Jess in Action][AskingGoodQuestions]
Michael Herrmann
Ranch Hand

Joined: Dec 06, 2003
Posts: 60
The first few chapters of this book (which you can legally read online if you follow the link) concern exactly what you've asked about.
 
Don't get me started about those stupid light bulbs.
 
subject: basic question...