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 是否可以同时运行多个程序?
基础教程推荐
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
