From: rubix Rubix Date: 2011-10-15T09:42:35+09:00 Subject: deadlock producer consumer Hi I make the following test #-------------------------------------------------- ProducerQueue = Containers::PriorityQueue.new ConsumerQueue = Containers::Queue.new mutex = Mutex.new access = ConditionVariable.new initialize ProducerQueue producer = Thread.new do loop do mutex.synchronize { while ProducerQueue.empty? do access.wait(mutex) end ProducerQueue.pop somework ConsumerQueue.push(result) access.signal } end end consumer = Thread.new do loop do mutex.synchronize { while ConsumerQueue.empty? do access.wait(mutex) end page = ConsumerQueue.pop() somework ProducerQueue.push(result) access.signal } end end consumer.join producer.join #---------------------------------------------------------- I keep having deadlock when executing it What is wrong with the code? I think may be I have to add an other ConditionVariable, the problem is the producer and the consumer use the two queues Any Ideas -- Posted via http://www.ruby-forum.com/.