Skip to content

Instantly share code, notes, and snippets.

@manavid
Created August 22, 2017 23:03
Embed
What would you like to do?
require 'concurrent'
pool = Concurrent::FixedThreadPool.new(8, idletime: nil)
100.times do |i|
pool.post do
rnd = SecureRandom.random_number(5)
puts "task #{i}: sleep #{rnd}"
sleep rnd
end
end
pool.shutdown
pool.wait_for_termination
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment