Why is there no GIL in the Java Virtual Machine? Why does Python need one so bad?(为什么Java虚拟机中没有GIL?为什么 Python 这么需要一个?)
问题描述
我希望有人能提供一些关于 Java 虚拟机的根本不同之处的见解,它允许它很好地实现线程而无需全局解释器锁 (GIL),而 Python 需要这样一个邪恶.
I'm hoping someone can provide some insight as to what's fundamentally different about the Java Virtual Machine that allows it to implement threads nicely without the need for a Global Interpreter Lock (GIL), while Python necessitates such an evil.
推荐答案
Python(语言)不需要 GIL(这就是为什么它可以完美地在 JVM [Jython] 和 .NET [IronPython] 上实现,并且那些实现多线程自由).CPython(流行的实现)一直使用 GIL 来简化编码(尤其是垃圾收集机制的编码)和非线程安全 C 编码库的集成(过去有很多这样的库;-).
Python (the language) doesn't need a GIL (which is why it can perfectly be implemented on JVM [Jython] and .NET [IronPython], and those implementations multithread freely). CPython (the popular implementation) has always used a GIL for ease of coding (esp. the coding of the garbage collection mechanisms) and of integration of non-thread-safe C-coded libraries (there used to be a ton of those around;-).
Unladen Swallow 项目以及其他雄心勃勃的目标,计划 用于 Python 的无 GIL 虚拟机——引用该网站的话,此外,我们打算移除 GIL 并修复 Python 中的多线程状态.我们相信这可以通过实现更复杂的 GC 系统来实现,例如 IBM 的 Recycler (Bacon et al, 2001)."
The Unladen Swallow project, among other ambitious goals, does plan a GIL-free virtual machine for Python -- to quote that site, "In addition, we intend to remove the GIL and fix the state of multithreading in Python. We believe this is possible through the implementation of a more sophisticated GC system, something like IBM's Recycler (Bacon et al, 2001)."
这篇关于为什么Java虚拟机中没有GIL?为什么 Python 这么需要一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么Java虚拟机中没有GIL?为什么 Python 这么需要一个?


- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01