Stéphane Ninin wrote:
> Hello,
>
> Probably a stupid question, but I am not a multithreading expert...
>
> I want to share a dictionary between several threads.
> Actually, I will wrap the dictionary in a class
> and want to protect the "sensitive accesses" with locks.
>
> The problem is I am not sure which concurrent access to the dictionary
> could cause a problem.
>
> I assume that two write's on the same location would be,
> but what if one thread does
>
> mydict['a'] = something
>
>  and another thread:
>
> mydict['b'] = something else
>
> Is a lock required in such a case ?

i dont think you need to use a lock for these cases because mydict['a']
refers to mydict['b'] memory locations (i may be wrong because i dont
know Python implementation).

Just a recomendation, you could also use a Queue object to control
write access to the dictionary.

-Cheers

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to