Java Thread: start () - How to create a new thread?

I was wondering what goes into the java thread start method so that it can create a new thread?

+4
source share
3 answers

As in Java, creating a thread using the start () method implies a JVM . What the Java Virtual Machine as a whole should do is mediate between method calls and the underlying operating system. This ensures that the Java environment works (approximately) the same regardless of the operating system (=> Java's famous mobility). But what he does behind the curtain (i.e. Inside the JVM) is different and depends on the actual operation of the OS.

, pthread_create ( POSIX) Unix CreateThread Windows ( API Win32). Java, .

. JVM ( OS-es, ) start() .

, , . start() , .

+1

, , Java, ++.

, , JVM, , JVM; Linux - pthread_create(), , , clone() . , Windows.

, Java : Java , , ; , ​​ , Java, , Java .

, , , , .

+2

A specific answer will be impossible, because it varies across the platform (in the distant past there were Green themes , and everything was clear - they ran like user level threads ). Since then, they have been replaced by Native threads as "optimizations." That is, green threads have been removed in favor of the idiomatic streaming processing model of their own operating system. Despite this, native code will eventually call your programmed method run.

+1
source

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


All Articles