I guess I just don’t understand why people are having so many problems with threading in Java.
Are you guys setting priorities or something? Are you using Thread.sleep (<— ABSOLUTE EVIL…can’t stress this enough) instead of Thread.yield? Are you using synchronized calls instead of synchronized blocks? Are you using a lock object at all?
If you use yield and default priorities, and put timmers in both your threads, you will see they are actually getting almost identical amounts of CPU always.
To control which gets more, use yield like I have in the code above. The engine thread gets only what it needs, no more, no less. The renderer/awt/ thread and awt threads gets everything else. The engine stays at a constant (I stress CONSTANT) 62 FPS regardless of if the rendere is doing 1400 FPS of nothing or 70 FPS of 28K tris. When the renderer is doing 70FPS that means the engine is heavily working as well calculating geometry for it…yet it remains constant because it can do all it needs to do in less then 15 ms.
If you find one thread is getting CPU for 5 seconds then the other is getting it, then something is wrong with how you have implemented your threading, like an unreleased lock, or a dead loop with no yielding at all.