another thread on Python threading

Josiah Carlson josiah.carlson at
Tue Jun 5 09:15:29 CEST 2007

sturlamolden wrote:
> On Jun 4, 10:11 pm, Josiah Carlson <josiah.carl... at>
> wrote:
>>      lock = threading.Lock()
>>      with lock:
>>          #synchronized block!
>>          pass
> True, except that the lock has to be shared among the threads. This
> explicit initiation of an reentrant lock is avoided in a Java
> synchronized block.

You toss the lock creation in the global namespace of the module for 
which you would like to synchronize access.

  - Josiah

More information about the Python-list mailing list