Re: Queue can result in nested monitor deadlock
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: Queue can result in nested monitor deadlock

From: Alan Morgan <amorgan@xenon.Stanford.EDU>
Date: Mon Apr 17 2006 - 20:30:24 CEST

In article <1145292096.906390.254280@e56g2000cwe.googlegroups.com>,
Jonathan Amsterdam <jbamsterdam@gmail.com> wrote:
>If you don't want to call it deadlock, fine, but the program execution
>I describe will make no progress to the end of time. Thread 2 can never
>put anything in the queue, because Thread 1 holds M, and Thread 1 will
>never release M because that can only happen if someone puts something
>on the queue.

That's not a problem in the design of the queue class, it is a problem
in how you are using it. Two possible solutions are:

1. Don't have the global lock on the object (or, at the very least,
   don't have that global lock taken when you read from the queue).
2. Don't use a syncronized queue. If the only access to the queue is
   through the object and the object is protected then you don't need
   a synchronized queue.

Alan

-- 
Defendit numerus
Received on Sun Apr 30 23:25:24 2006