Affinity in Java thread

0 votes

How do we lock down the individual threads contained within the Java processes that are specific to the CPU core. Any suggestion will be helpful.

Oct 30, 2018 in Java by 93.lynn
• 1,590 points
46 views

1 answer to this question.

0 votes

Well, as far as I know, I don't think Java allows that.

But you can use an underhand method where you need to make use of JNI in order to invoke the native codes that will execute the program. For more detail, you can refer here:

http://ovatman.blogspot.com/2010/02/using-java-jni-to-set-thread-affinity.html

http://blog.toadhead.net/index.php/2011/01/22/cputhread-affinity-in-java/

answered Oct 30, 2018 by code.reaper12
• 3,450 points

Related Questions In Java

0 votes
2 answers
0 votes
1 answer

How can you catch an exception thrown by another thread in Java?

This can be done using Thread.UncaughtExceptionHandler. Here’s a simple ...READ MORE

answered Dec 3, 2018 in Java by Frankie
• 9,810 points
2,553 views
+5 votes
3 answers

How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

answered Mar 27, 2018 in Java by DragonLord999
• 8,380 points

edited Nov 6, 2018 by Omkar 11,251 views
+1 vote
3 answers

What is the syntax to declare and initialize an array in java?

You can use this method: String[] strs = ...READ MORE

answered Jul 25, 2018 in Java by samarth295
• 2,190 points
702 views
0 votes
1 answer

difference between wait() and sleep() in java

We can find a big difference between ...READ MORE

answered Apr 25, 2018 in Java by developer_1
• 3,300 points
83 views
0 votes
1 answer

How to kill a thread in Java?

You can use a shared variable as ...READ MORE

answered Jun 6, 2018 in Java by Akrati
• 3,150 points
95 views
0 votes
1 answer

How to stop the Thread in Java?

Use a flag, which will indicate the ...READ MORE

answered Jun 11, 2018 in Java by parth295
• 4,640 points
111 views
0 votes
1 answer

Gracefully stopping a java thread

The preferable way will be to use a ...READ MORE

answered Aug 20, 2018 in Java by anto.trigg4
• 3,420 points
45 views
0 votes
1 answer

Purpose of “String args[]” in the “psvm” of Java

Let me give you the complete explanation ...READ MORE

answered May 7, 2018 in Java by code.reaper12
• 3,450 points
118 views
0 votes
1 answer

Need for finalize() in Java

finalize() is a method called by the ...READ MORE

answered May 8, 2018 in Java by code.reaper12
• 3,450 points
89 views