8
votes

What is the easiest way in Java for achieving multi-core? And by this, I mean, to specifically point out on what core to execute some parts of the project, so good-old "normal" java threads are not an option.

So far, I was suggested JConqurr (which is an Eclipse toolkit for multi-core programming in java), JaMP (which extends Java for OpenMP), and MPJ express, of which I don't know much. Which of the above do you consider the best, or do you have other suggestions? It would be preferable to somehow mesure the performance boost/gain, but not exclusive.

Any help would be much appreciated. Thanks, twentynine.

2
Is that terminology ("achieving multi-core") used anywhere? I would change this question to "Running threads on specific Cores in Java" - ripper234
I believe the term is "processor affinity", which applies to cores as well as processors. - ide
Why exactly do you need to be able to set processor affinity for the threads? Why not let the JVM handle those decisions? - Darien

2 Answers

2
votes

Even though it is easy to write multi-threaded code in Java, there is nothing in the Java standard runtime which generically allow you to tell the JVM or the operating system how to schedule your program.

Hence you will need to have code specifically for your JVM and/or your operating system, and that code may not be doable in Java (unless you dive into JNI or JNA). External programs can pin processes to a CPU in many Unix versions (and probably Windows too), but I don't think you can do this for individual threads.

0
votes

Scala is quite popular for this. It runs on the JVM and has bindings for Java to hook them together.