How are Java threads scheduled?

Guys, I recently started programming with Java in the case of Linux threads, I know that the kernel plans them (since they are single entities that are planned), but java programs run on JVMs that are implemented on my system (RHEL 6.1) as a program that runs as a user space. Thus, if the kernel does not know about java threads, how does this happen, does proactive multitasking run in the JVM? it will be useful if the whole mechanism of interaction between the JVM and the kernel is given when performing this task. Plz cites possible sources of information

+5
source share
4 answers

The themes of the java / JVM process are mapped to a native thread, and you can see both the java thread id and the native thread id in the thread stack trace dump. Get the stack thread of all java threads with your favorite tool:

  • command line signal, such as ctrl + break (windows) or ctrl + \ linux) in the console where the java program is running.
  • command line tool (kill -QUIT or jstack from jdk)
  • visual vm in jdk and / or jmx etc.

An example from the first line of such a stream dump: ... tid = 0x0000002adaba9c00 nid = 0x754c ...

  • tid = java thread id

  • nid = native identifier (id of the OS thread)

Use the operating system tools to learn more about the stream using its own identifier (it is in hexadecimal format).

java- ThreadMXBean , http://docs.oracle.com/javase/6/docs/api/java/lang/management/ThreadMXBean.html

+3

Java ? , Java - , JVM-.

+2

jvm - , , . - . ( libs) - jvm . Google posix threads - , (API) jvm.

: http://www.ibm.com/developerworks/java/library/j-rtj3/

+1

", java- JVM, (RHEL 6.1) , . , java..."

This statement is not true for all modern JVMs that use native threads. I think this was the default with Java 1.2. Implementing Native Thread using the JVM means that every time a thread creates / starts a thread in Java code, the JVM asks the OS to create a thread. Since they are native threads, the kernel knows about them and processes them accordingly. In addition, Linux supports / implements POSIX threads, and as such on Linux-based systems, you get pthread behavior for the threads of your Java applications

0
source