JVM 和 Java Linux 进程

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4301531/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 00:10:02  来源:igfitidea点击:

JVM and Java Linux process

javalinuxmultithreadingjvm

提问by Gnanam

This question may be very basic about Java JVM. If I've a Java standalone program and if, for example, 5 processes of this program are running at a particular time in the server, can we say that these 5 java processes are running in 5 JVMs?

这个问题可能是关于 Java JVM 的非常基础的问题。如果我有一个 Java 独立程序,并且例如,该程序的 5 个进程在服务器中的特定时间运行,我们可以说这 5 个 Java 进程在 5 个 JVM 中运行吗?

By process, I mean the Linux process here. If I execute ps -ef |grep java, I'll see 5 java processes showing up.

通过进程,我指的是这里的 Linux 进程。如果我执行ps -ef |grep java,我会看到 5 个 java 进程出现。

采纳答案by Matthew Flaschen

Yes, that's correct. There is one JVM per javaprocess.

对,那是正确的。每个java进程有一个 JVM 。

回答by Jé Queue

Depends on the JVM and native libs. You may see JVM threads show up with distinct PIDs in ps. Generally speaking the child PIDs will have parent PIDs with java processes as those that are threads.

取决于 JVM 和本机库。您可能会看到 JVM 线程在ps. 一般来说,子PID将具有Java进程作为线程的父PID。

You cannot say for sure that the # of Linux java processes == # of instantiated JVMs.

您不能肯定地说 Linux java 进程数 == 实例化 JVM 的数量。

回答by CruiZen

You can run the jpscommand (from the bin folder of JDK if it is not in your path) to find out what java processes (JVMs) are running on your machine.

您可以运行该jps命令(如果它不在您的路径中,则从 JDK 的 bin 文件夹中)找出您的机器上正在运行的 Java 进程(JVM)。