Problem in threading

Mike Meyer mwm at mired.org
Thu Dec 30 16:45:32 EST 2004


Peter Hansen <peter at engcorp.com> writes:

> Mike Meyer wrote:
>> Python's threading models is pretty primitive. You get the C
>> model (which is error-prone), the Java model (in 2.4, and also
>> error-prone), or Queues.
> Can you please expand on your words above?  I have no idea
> what you are talking about with the "Java model" and your
> implication that it is something new in Python 2.4.  As
> far as I know, nothing significant with respect to threads
> has changed in Python recently.

See <URL: http://docs.python.org/lib/module-threading.html > which
clearly has the words "New in 2.4" on it. It also says that the
threading module is loosely based on the Java model.  I may have
misinterpreted what the "New in 2.4" applies to, which means that the
comment about the Java model being new in 2.4 would be wrong.

As for error-prone, both models require the programmer to always
obtain locks around critical sections, and to obtain them in an order
that prevents deadlocks, and release them in an order that prevents
starvation.

There are threading models that don't require the programmer to get
the locking right. In those, you basically declare an object as
running on a different thread, and the compiler provides the
appropriate locks for each method. I went looking for a reference to
one such method, but couldn't turn it up, partly because I don't
recall whether I saw it on usenet or a mail list.

       <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list