Possible Duplicate:
Java thread affinity
I have a server and it has a 16 cores cpu.
In Java, I need to create some threads (the number of threads is less than 16). Each thread needs to run some operations, e.g., process an event queue.
How can I create these threads so that it guarantees that each thread is assigned to one core forever? I mean I don't want the OS exchanging cores for one thread. I just wish one thread is dedicatedly running on a fixed core.
Can I do that?
The reason I want this is
I handle some background tasks (computation intensive) and some user-facing tasks in the same server. I don't want the user side get any negative impact. For example, if my computation tasks are assigned to 16 cores, surely the threads which are running for user side will be negatively affected, right?
You cant. JVM virtualizes all hardware so you can not do anything like that.
There could be some 'tricks' that would work on some specific architecture and some specific JVM, but it would all be hackish and unreliable.
Don't waste your valuable development time on this. Fix some other problems. If the time taken by OS core menagement is an issue for your app, it's teetering on the edge of failure anyway.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With