See the forum where someone asked the Python multithreading and C + + multi-threading differences?
The warm God replied:
Python has global interpreter Lock, so ... You know.
C++11 began to be multi-threaded, using shared memory for inter-thread communication, with low-level atomic operation and memory order, and advanced lock, condition, but did not provide Message Queuing.
Then, to find the definition of Gil (Global interpreter Lock), here is a definition, as defined by the wiki. Another more popular explanation was seen on the StackOverflow:
Suppose you has multiple threads which don ' t really touch each of the other S data. Those should execute as independently as possible. If you had a "global lock" which you need to acquire in order to (say) call a function, which can end up as a bottleneck. Getting much benefit from having a multiple threads in the first place.
To put it into a real world analogy:imagine of developers working at a and only a single coffee mug. Most of the developers would spend their time waiting for coffee instead of coding.
None of this are python-specific-i don ' t know the details of what Python needed a GIL-in-the-first place. However, hopefully it's given you a better idea of the general concept.
Probably understand a basic meaning: Gil (Global interpreter Lock) will serialize thread access, so in the case of the Gil Lock, the advantages and characteristics of multithreading can not really play out. There is not even a single thread to run fast, because additional thread scheduling instructions are executed when acquire and Relea are locked. This Gil is only in the CPython, convenient loading C Extension,jython and IronPython inside is wood. So, in Python, you should use a smaller-grained lock?
Speaking of C + +, the above warm God said atomic operation, is the atomic lock, specific here has a clear explanation, atomic is a good thing .... As for the memory order, said not to understand ... Take the mutex with you honestly ...
Python multithreading and C + + multi-Threading differences