Critical sections and mutexes

David Bolen db3l at fitlinxx.com
Thu Oct 25 00:36:05 EDT 2001


<brueckd at tbye.com> writes:

> I do see your point, but I think of it from the opposite point of view: a
> newbie learning about threads would be thrilled to get a simple
> producer/consumer program working to play around with. Once they see how
> cool it is, then you move on to teaching them about locking problems,
> mutexes, etc. And hopefully, they played with it enough already to get
> bitten by a problem so that they really understand the lesson.

If that's what the newbie wants, they should be pointed to an
appropriate class (like the Queue) that specifically provides simple
producer/consumer behavior with all the appropriate locking hidden
within the class.  I don't think suggesting that they just write their
own without such locking (which can lead to believing it isn't
necessary) is to their benefit, even if it makes the problem seem
simpler.

To my mind, the benefit Python has for newbies is that the typical
housekeeping required of multithreading applications _and_ the types
of synchronization that is a fact of life for such applications are
very simple to use.  And a number of useful classes are provided for
common scenarios within multithreaded applications.

BTW, one of the reasons I feel strongly about this is that a very
large percentage of my applications over the years have been
multithreaded (and I'm a big fan of having the support in the language
such as Python does) and there are just some things you don't skimp
on, if you want to do it write, maintainably and with assured behavior
over time.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list