Skip to content

Instantly share code, notes, and snippets.

@hayamiz
Created January 17, 2010 13:26
Show Gist options
  • Save hayamiz/279371 to your computer and use it in GitHub Desktop.
Save hayamiz/279371 to your computer and use it in GitHub Desktop.
require 'thread'
$queue = Queue.new
workers = Array.new(100).map do
Thread.new do
block = $queue.pop
block.call()
end
end
100.times do
$queue.push(lambda {
pid = Process.fork do
puts :hoge
end
Process.waitpid(pid)
})
end
workers.map(&:join)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment