Created
January 10, 2018 18:46
-
-
Save stravid/f38627aaa065b0276e550787003fafb6 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 "rubygems" | |
require "bundler/setup" | |
require "concurrent" | |
tasks = 10.times.map do |s| | |
Concurrent::TimerTask.new(execution_interval: 1) do | |
sleep s | |
puts "s: #{s}\n" | |
end | |
end | |
begin | |
tasks.each { |t| t.execute } | |
sleep | |
rescue Interrupt | |
puts "Received INT" | |
puts "Shutting down tasks" | |
tasks.each { |t| t.shutdown } | |
ensure | |
puts "Releasing resources" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment