开发者

How can I use my multiple cored dedicated server to run my java application?

I have a game built in a java environment and I use JVM.

I have 4 cores @ 2.4Ghz and my server is only using one of those cores...

I've tried and searched and I still have no guides to setup multiple cores to run the game like, say 1 core for running the character saving + loading, and 1 core for the server itself, and 1 core for a helper to help other cores that need more power.

I don't even know if this is开发者_高级运维 possible but this is all in java the operating machine is windows server 2003 and I've tried so hard I just don't know what to do.

May someone please help me!

Thank you so much!


You cannot directly delegate tasks to specific CPU cores with Java, but if you implement your program using multiple threads (either directly or by using the executor utility classes in java.util.concurrent), the OS will run the different threads/tasks on different cores if it is possible.

To achieve this, you must of course understand the basics and pitfalls of multithreaded programming, learn how to exchange data safely between threads, prevent that several threads access and modify critical data simultaneously and so on. That topic however is far too broad to summarize here in a short answer.


Java by default will take advantage of multiple cores. Unfortunately, an app must be specifically coded to be multithreaded. It's likely that the game is running everything in the Event Dispatch Thread. The application would need to be changed in order to take advantage of multiple cores.

On the bright side, processors like the Core i5 can detect when only a single core is being used, and can over-clock that single core. This helps programs which aren't or can't be multithreaded.


One can also code multiple JVMs and each JVM can be bound to a set of CPUs, with the necessary RMI between them. This can be programming-related.


Some clarilty on that@Xepoch? I understand the RMI part, but how JVM can be bound to set of CPUs. Remember here I am talking about 4-core processors so thats 4 CPUs for me instead of 4 single-core processors.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜