Last active
May 14, 2017 00:02
-
-
Save bxt/d2504617c6dfc8dd201b11b9d9b58886 to your computer and use it in GitHub Desktop.
Fork test in Crystal lang
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
puts "Starting..." | |
forks = 10.times.map do |i| | |
fork do | |
puts "In fork #{i}" | |
sleep(i) | |
puts "End fork #{i}" | |
end | |
end.to_a | |
puts "Forked everything." | |
forks.each do |f| | |
f.wait unless f.terminated? | |
end | |
puts "Done waiting." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment