Search code examples
javamultithreadingmulticore

How to ensure that a thread is executed in another CORE?


Trying to execute a thread in another core, i use java.util.concurrent.executor

I dont know if its enough to make the thread running in another core so, i want to know in witch core every thread is executed.

Any idea?

Executor executor = Executors.newSingleThreadExecutor();            
executor.execute(new Runnable() {       
             //some work
});

Solution

  • This was discussed in more detail in this post: Java thread affinity

    Some code popped out here.

    The idea is to set affinity of the thread by making a native call through JNI and set the affinity from native code.