If I am not wrong, JVM relies on underlying architecture of OS for scheduling and spreading threads to other cores (when a thread is spawned). However, in my application, I don't see it happening. Each and every thread is running on 0th core and rest N-1 cores are in idle states. Any specific reason why this is happening and, more over, how to solve this issue so that I can utilize rest of my cores ?
I am aware of setting process affinity but that is, in a way, hardcoding a process to a specific core. Since a thread can be spawned at any given point, it should idly be processed by a core sitting idle.
Code Snippet e.g.
public static void main() {
R1 r1 = new R1();
R2 r2 = new R2();
Thread t1 = new Thread(r1);
Thread t2 = new Thread(r2);
t1.start();
t2.start();
}
Any suggestion ?