I had a Java program that I run thousand times based on a loop (according to the number of files to be compiled to build a linux kernel) in a bash script.
There was a performance problem since the jvm was started several times…
What i’ve done then is implementing a wrapper in java that does the same as my bash script, reads one line from a file and then calls the main of my previous program… This way, I only have one jvm running…
The problem now is that only one core of my box is used which is another performance issue… Do I have to start some threads or can I use the same method but maybe calling the “former” main in a different way ?
If i have to start some threads, how I dispatch them throughout the multiple cores ?
thanks…
Your java program needs to become multi-threaded, in order to take advantage of many cores.
For example, create a thread pool using java.util.concurrent.Executors, encapsulate your data items as a Runnable, and submit the Runnable to the threadpool.