简体   繁体   English

JVM在创建线程时如何使用操作系统?

[英]How JVM use operating system when creation of thread?

Here i try to learn java thread clearlly.. On which process JVM create the thread.在这里,我尝试清楚地学习 java 线程。在哪个进程 JVM 创建线程。 Suppose if i create a thread in java then how JVM create this thread?假设如果我在 java 中创建一个线程,那么 JVM 如何创建这个线程? To whom it will send to exicute?.. Which one is the base process for this...它将发送给谁执行?.. 哪个是此的基本过程...

Most JVMs use standard OS calls to create native threads (eg, the Win32 CreateThread API, or POSIX pthread_create ), and pass a native function within the JVM which proceeds to execute the Java code in the thread. Most JVMs use standard OS calls to create native threads (eg, the Win32 CreateThread API, or POSIX pthread_create ), and pass a native function within the JVM which proceeds to execute the Java code in the thread.

There is a separate JVM process for every running Java application.每个正在运行的 Java 应用程序都有一个单独的 JVM 进程。 The threads that the application creates are created within that process.应用程序创建的线程是在该进程中创建的。

Actually the Java Virtual Machine Specification does not specify how threads are to be handled by a JVM.实际上,Java 虚拟机规范没有指定 JVM 如何处理线程。 There is only a high level description .只有高级别的描述 The Sun JVM itself made a change in this regard: Up to Java 1.1 it used so called Green Threads that are managed by the JVM itself. Sun JVM 本身在这方面进行了更改:直到 Java 1.1 它使用由 JVM 本身管理的所谓的绿色线程 Later it used native threads that the host operating system provides.后来它使用了主机操作系统提供的本机线程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM