Skip to content

Instantly share code, notes, and snippets.

@nbarraille
Created December 10, 2012 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nbarraille/4252650 to your computer and use it in GitHub Desktop.
Save nbarraille/4252650 to your computer and use it in GitHub Desktop.
Threadz not finishing
require 'rubygems'
require 'threadz'
def dostuff(i)
sleep 1
raise "Exception" if i == 4
end
tp = Threadz::ThreadPool.new
batch = tp.new_batch
[1,2,3,4,5].each do |i|
batch << lambda { dostuff(i) }
end
puts "Wait"
batch.wait_until_done
puts "Comes here"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment