Created
October 7, 2011 04:49
-
-
Save qmx/1269466 to your computer and use it in GitHub Desktop.
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
qmx@gondor ~/tmp » jruby threads.rb | |
starting thread 1 | |
starting thread 0 | |
starting thread 2 | |
starting thread 3 | |
starting thread 4 | |
ending thread 2 | |
ending thread 3 | |
ending thread 1 | |
ending thread 0 | |
ending thread 4 | |
qmx@gondor ~/tmp » |
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
threads = [] | |
5.times do |i| | |
threads << Thread.new do | |
puts "starting thread #{i}" | |
sleep 2 | |
puts "ending thread #{i}" | |
end | |
end | |
threads.each do |thread| | |
thread.join | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment