Possible Duplicate:
How do I spawn threads on different CPU cores?
I am using C#. I want to write the program using the threading concept. I just want to know how to run the threads in different processors. Here I attach my partial code:
Thread t1 = new Thread(threadJobA);
Thread t2 = new Thread(threadJobB);
t1.Start();
t2.Start();
The short answer, like I said in my comment is: “Don’t worry about it.” If you have to ask this question, it is definitely not worth any amount of effort you’d put forward.
That said, the way to really do this is to set the “Thread Affinity Mask” which controls which logical processor the thread is allowed to run on. I’m not sure you can even do this with CLR threads (it may blow up and the world will end.) But if you have a plain ol’ thread, created using
CreateThread, then you can set the affinity mask usingSetThreadAffinityMask.But really. Don’t do this.