Threading - Why Not Lock Objects Rather than lock the interpreter

Daniel Dittmar daniel.dittmar at sap.com
Fri Dec 5 12:26:06 EST 2003


Fuzzyman wrote:
> Looking at threading code it seems that the Global Interpreter Lock is
> a bit of a 'brute force' way of preventing two threads attempting to
> access sensitive objects simultaneously....
>
> Why not have a new type of object with a 'lock' facility... if an
> object is locked then any thread trying to access the object other
> than the one obtaining the lock is blocked until the lock is
> released..... rather than blocking *all* threads until one thread has
> finished with the object.....

Because the reference counter of objects has to be synchronized.

Daniel







More information about the Python-list mailing list