1

Possible Duplicate:
Java thread affinity

I would like to test my 2-thread program running each thread on its own physical processor. I heard in linux you can PIN a thread to a certain processor so it stays there. Is there some kind of library in Java (using native code of course) that would allow me to do that? If not, can a Linux guru describe how do I pause my JVM, list my Java threads, get their native id and run some kind of linux command to PIN them? Then I can resume my JVM and the threads will bind to their assigned processor.

Community
  • 1
  • 1
TraderJoeChicago
  • 6,205
  • 8
  • 50
  • 54
  • What is your goal? If you have 2 threads and 2 processors, most time each thread would run on a separate processor, and from time to time processors would swap their threads. Why does it matter for you? – Alexei Kaigorodov Apr 16 '12 at 16:41
  • @AlexeiKaigorodov There are other threads in the OS and in my JVM, right? So my goal is to never allow (or to avoid the most I can) having my two threads running in the same physical processor. – TraderJoeChicago Apr 16 '12 at 16:42
  • @SergioOliveiraJr. I recommend looking at both the most upvoted answer and the accepted answer in the duplicate question. – trutheality Apr 16 '12 at 16:43
  • @trutheality Yeah. I see now it is a duplicate. Thx! – TraderJoeChicago Apr 16 '12 at 16:50

0 Answers0