thread lock object.
Irmen de Jong
irmen.NOSPAM at xs4all.nl
Sun Apr 24 10:08:08 EDT 2005
ajikoe at gmail.com wrote:
> Hello,
>
> I have multi thread program running together and each will increment
> int i.
>
> How can we make only one thread at a time be able to access and
> increment i ?
>
> Thanks in advance,
>
> Sincerely Yours,
> pujo
>
Use a synchronization primitive such as a lock
(threading.Lock, threading.RLock)
But for simply incrementing a number (i+=1) this is not needed
because that operation cannot be interrupted by another thread,
as far as I know.
--Irmen
More information about the Python-list
mailing list