Global interpreter lock

A global interpreter lock (GIL) is a mechanism used in computer-language interpreters to synchronize the execution of threads so that only one native thread (per process) can execute basic operations (such as memory allocation and reference counting) at a time.

[1] As a general rule, an interpreter that uses GIL will see only one thread to execute at a time, even if it runs on a multi-core processor, although some implementations provide for CPU intensive code to release the GIL, allowing multiple threads to use multiple cores.

Due to signaling with a CPU-bound thread, it can cause a significant slowdown, even on single processors.

JVM-based equivalents of these languages (Jython and JRuby) do not use global interpreter locks.

IronPython and IronRuby are implemented on top of Microsoft's Dynamic Language Runtime and also avoid using a GIL.

Schematic representation of how threads work under GIL. Green - thread holding GIL, red - blocked threads