Skip to content

Instantly share code, notes, and snippets.

@qmx
Created October 7, 2011 04:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qmx/1269466 to your computer and use it in GitHub Desktop.
Save qmx/1269466 to your computer and use it in GitHub Desktop.
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 »
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