Is it possible for a JVM to run more than one program at the same time?(JVM 是否可以同时运行多个程序?)
问题描述
JVM 可以同时运行多个程序吗?如果是这样,怎么做?如果不是,为什么?
Is it possible for a JVM to run more than one program at the same time? If so, how? If not, why?
要运行程序,我们只需这样做
To run a program, we simply do
java ProgramName
但是我们可以使用同一个 JVM 实例来运行另一个程序吗?
But can we use the same JVM instance to run another program?
推荐答案
答案取决于你对程序"的定义.具有 main
方法并且以 java NameOfClass
开头的 Java 程序通常不能在同一个 JVM 中运行,因为没有内置的资源或命名空间分离.例如,如果两个程序使用相同库的冲突版本怎么办?
The answer depends on your definition of "program." The Java programs that have a main
method and that you start with java NameOfClass
typically cannot be run in the same JVM because there's no builtin separation of resources or namespaces. For example, what if the two programs use conflicting versions of the same library?
我们还有旨在共享 JVM 的应用程序,例如企业应用程序.这些程序旨在在应用程序服务器"的上下文中运行,该程序基本上是用于运行其他程序的程序.应用程序服务器使用类加载器和安全管理器将应用程序资源分开.例如,由于通过不同的类加载器加载,两个应用程序可能使用冲突的库版本或冲突的类名,但仍然共享一个 JVM.
We also have applications that are designed to share a JVM, such as enterprise applications. These are programs that are designed to run in the context of an "application server", which is basically a program for running other programs. An application server keeps the applications resources separate using classloaders and security managers. For example, two applications may use conflicting versions of a library or conflicting class names and still share a JVM thanks to being loaded through different classloaders.
这篇关于JVM 是否可以同时运行多个程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:JVM 是否可以同时运行多个程序?
基础教程推荐
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 降序排序:Java Map 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01