Guest User

Untitled

a guest
Sep 12th, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.51 KB | None | 0 0
  1. class Chunky_bacon
  2.     def sizzle
  3.         puts "I'm sizzling, eat me"
  4.     end
  5. end
  6.  
  7. chunky_bacon = Chunky_bacon.new
  8. chunky_bacon_queue = Queue.new
  9. chunky_bacon_queue << chunky_bacon
  10.  
  11. 5.times.map do
  12.   Thread.new do
  13.     begin
  14.       chunky_bacon = chunky_bacon_queue.pop(true)
  15.       chunky_bacon.sizzle!
  16.   end
  17. end.each(&:join)
  18.  
  19. =====
  20.  
  21. #This is happening 5x. But for starters, doesn't there have to be 5 objects added to the queue for it to work? Seems like there are 5 items "popped" out of the queue, but not 5 going in.
Advertisement
Add Comment
Please, Sign In to add comment