全局解释器锁(Global Interpreter Lock),是计算机程序设计语言解释器用于同步线程的工具,使得任何时刻仅有一个线程在执行。常见例子有CPython(JPython不使用GIL)与Ruby MRI。
全局解释器锁用于保护当前线程状态的指针。
The global interpreter lock is used to protect the pointer to the current thread state.
当前拥有全局解释器锁的线程(或其它什么)未知时,调用这个函数不安全。
It is not safe to call this function when it is unknown which thread (if any) currently has the global interpreter lock.
释放全局解释器锁。锁必须提前创建。这个函数在编译时禁用线程支持的情况下不可用。
Release the global interpreter lock. The lock must have been created earlier. This function is not available when thread support is disabled at compile time.
应用推荐