Chris Wailes wrote: > I know it's an odd combination, but I have a situation where a thread > pulls a fiber off of a queue and then calls `resume` on it. I used to > use Proc objects but I need the ability to stop and start the jobs while > they are being executed so I switched to Fibers. > > The problem I am having is that the thread hangs once it calls `resume`. > As far as I can tell nothing inside the fiber gets executed. Does > anyone know why this might be happening? > > I'm currently using Ruby v 1.9.1p243. $ ruby19 -v ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-darwin8.11.1] require 'thread' q = Queue.new thr = Thread.new do f1 = Fiber.new do puts "hello" Fiber.yield puts "world" end f2 = Fiber.new do puts "goodbye" Fiber.yield puts "world" end q.push(f1) q.push(f2) q.push(q) while (f = q.pop) != q f.resume f.resume end end thr.join --output:-- hello world goodbye world -- Posted via http://www.ruby-forum.com/.