-
-
Save adam12/793d9ea97815cdda37bdfad64202dda0 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 "async" | |
require "async/barrier" | |
Async do |task| | |
barrier = Async::Barrier.new | |
barrier.async do | |
puts "Inside task 1" | |
sleep 20 | |
puts "Task 1 done" | |
end | |
barrier.async do | |
puts "Inside task 2" | |
sleep 10 | |
puts "Task 2 done" | |
end | |
barrier.async do | |
puts "Inside task 3" | |
sleep 2 | |
puts "Task 3 done" | |
end | |
puts "Waiting" | |
barrier.wait | |
puts "Done" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment