Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.