Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Java handle multithreading?

How does Java decide which core to assign a thread or a process? Is there any way to control that? to prevent two large threads from executing on the same core?

Basically what I am asking is for further information on either how multi-threading works in Java, or how to control it within Java.

like image 832
badcodenotreat Avatar asked Feb 27 '23 07:02

badcodenotreat


1 Answers

You can't set processor affinity for specific Threads. But if you split your program into two processes, you should be able to assign those processes to specific processors at the OS level.

http://www.cyberciti.biz/tips/setting-processor-affinity-certain-task-or-process.html

like image 71
Tim Bender Avatar answered Mar 05 '23 16:03

Tim Bender