From: Sean O'Halpin Date: 2011-10-16T06:02:04+09:00 Subject: Re: deadlock producer consumer On Sat, Oct 15, 2011 at 9:52 PM, rubix Rubix wrote: > thanks Sean, > > I have a version with PriorityQueue from algorithms gem to pop the item > with the highest priority first but I had the problem of deadlock > but I tried today before your post a version with two standard queue but > it doesn't work too, > I don't know why you add the lines : > --------------- > item[:consumer] += 1 > ---------------- > and That's just to show that the producer and consumer threads are processing the item as it gets passed back and forth. > ---------------------- > # start things off > producer_queue.push({ :producer => 0, :consumer => 0}) > # either will work > #consumer_queue.push({ :producer => 0, :consumer => 0}) > ------------------------------ You need at least one item in either queue to get the ball rolling. Regards, Sean