[Python-ideas] Monitor implementation for the stdlib?

George Sakkis george.sakkis at gmail.com
Mon Oct 22 14:59:46 CEST 2007

On 10/22/07, Adam Olsen <rhamph at gmail.com> wrote:

> A method is often *NOT* the
> correct granularity to achieve a thread-safe API!  Consider:
> l = ... some "thread-safe" list ...
> if l:
>     x = l.pop()
> There's two method calls, so you cannot guarantee the object hasn't
> changed between them.  I get the impression this is regarded as a
> major mistake in Java's extensive use of monitors - plastering locks
> everywhere just isn't good enough.

My Java's kinda rusty but IIRC one can use synchronized blocks on an
object to achieve finer granularity.


More information about the Python-ideas mailing list