Why is there no GIL in the Java Virtual Machine? Why does Python need one so bad?

后端 未结 5 723
青春惊慌失措
青春惊慌失措 2020-12-04 05:18

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

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-04 06:13

    In this link they have the following explanation:

    ... "Parts of the Interpreter aren't threadsafe, though mostly because making them all threadsafe by massive lock usage would slow single-threaded extremely (source). This seems to be related to the CPython garbage collector using reference counting (the JVM and CLR don't, and therefore don't need to lock/release a reference count every time). But even if someone thought of an acceptable solution and implemented it, third party libraries would still have the same problems."

提交回复
热议问题