Created
August 22, 2017 23:03
-
-
Save manavid/a577c8503df683087d98d3ebba5aeaf9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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