How does Java handle multithreading?

How does Java decide which kernel assigns a thread or process? Is there any way to control this? to prevent the execution of two large threads on the same core?

Basically what I am asking is additional information on how multithreading works in Java or how to control it in Java.

+4
source share
4 answers

You cannot configure processor affinity for specific topics. But if you divide your program into two processes, you can assign these processes to specific processors at the OS level.

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

+4
source

Here is a tutorial on Multithreading in Java .

As for thread scheduling, the operating system should handle thread scheduling accordingly. You usually do not need to worry about this.

The Java Thread class does not currently provide a method for manually setting a thread binding, although this has been suggested in the past.

+2
source

How does Java decide which kernel to assign a thread or process to?

This is not true. The operating system does.

Is there any way to control this? Q prevent two large threads from running on the same core?

Not inside Java.

Basically what I am asking for is additional information on how multithreading works in Java or how to manage it in Java.

Not. All this is done by the OS.

Basically you are asking the wrong question.

+1
source

It really depends on the JVM implementation, but overall the Java implementation is based on the functionality of the streaming OS. As far as I know, there are no public and standard extensions to establish proximity. However, there may be experimental JVMs that offer hooks.

Also, interfering with the JVM abstraction to get confused directly with the underlying platform goes to a certain extent (and IMHO) against the spirit of Java.

0
source

Source: https://habr.com/ru/post/1305501/


All Articles