[Tutor] why list is not thread-safe, but deque and queue are thread-safe?

Lion Chen chnlion79 at gmail.com
Wed May 2 18:13:26 CEST 2012


i have read it, as the "Answer" said, seems like deque is not 
thread-safe either, because deque has the operator +=, and others like that.

i got some material about atomoperation from google:

An operation during which a processor 
<http://www.webopedia.com/TERM/M/microprocessor.html> can simultaneously 
read <http://www.webopedia.com/TERM/R/read.html> a location and write 
<http://www.webopedia.com/TERM/W/write.html> it in the same bus 
<http://www.webopedia.com/TERM/B/bus.html> operation. This prevents any 
other processor or I/O <http://www.webopedia.com/TERM/I/I_O.html> device 
<http://www.webopedia.com/TERM/D/device.html> from writing or reading 
memory until the operation is complete./
Atomic/ implies indivisibility and irreducibility, so an atomic 
operation must be performed entirely or not performed at all.

so deque is not thread-safe either. right?
> http://stackoverflow.com/questions/6319207/are-lists-thread-safe
>
>
>
> On Wed, May 2, 2012 at 7:58 PM, Lion Chen <chnlion79 at gmail.com 
> <mailto:chnlion79 at gmail.com>> wrote:
>
>     Hi, All,
>     i can not understand why list is not thread-safe, but deque and queue
>     are thread-safe?
>
>     that's all. thanks.
>
>     Lion Chen
>     _______________________________________________
>     Tutor maillist - Tutor at python.org <mailto:Tutor at python.org>
>     To unsubscribe or change subscription options:
>     http://mail.python.org/mailman/listinfo/tutor
>
>
>
>
> -- 
> http://spawgi.wordpress.com
> We can do it and do it better.



More information about the Tutor mailing list