Created
October 25, 2013 04:06
-
-
Save daimatz/7149340 to your computer and use it in GitHub Desktop.
Proc オブジェクトを単純に並列実行する例
This file contains hidden or 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
f = Proc.new { puts "start f"; sleep 10; puts "end f" } | |
g = Proc.new { puts "start g"; sleep 5 ; puts "end g" } | |
puts "start" | |
[f, g].map{ |prc| Thread.new{ prc.call } }.map(&:join) | |
p Thread.list | |
puts "all end" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment