threading

Sturla Molden sturla.molden at gmail.com
Tue Apr 8 06:47:43 EDT 2014


Marko Rauhamaa <marko at pacujo.net> wrote:

> The main problems with threads include:
> 
>  * Thread-safety is rarely done right. Also, when it's done wrong, it
>    can be virtually impossible to fix it without a significant rewrite.
>    This is not a theoretical concern: I have had to deal with the
>    resulting nightmares in my work.
> 
>  * There is no accepted, taught, industry-wide discipline on proper
>    thread-safety practices so every developer has to improvise. I have
>    come up with a "bullet-proof" way of developing with threads, but
>    even that methodology has nasty corner cases.
> 
>  * Thread-safety cannot be abstracted out. IOW, divide and conquer
>    doesn't work. You can't hide the locking inside a class and forget
>    about it. The entire application must be aware low-level thread
>    synchronization needs.

The problem here is the belief that "thread-safety cannot be abstracted
out". It can. The solution is to share nothing and send messages through
queues. If you start to use mutexes and conditions all over your code, you
might shoot yourself in the foot, eventually.   

Sturla




More information about the Python-list mailing list