Created
October 21, 2011 09:21
-
-
Save ha1t/1303429 to your computer and use it in GitHub Desktop.
ruby thread example
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 "Test start" | |
puts "Create thread" | |
message = ARGV[0] ||= '0' | |
begin | |
t = Thread.new do | |
puts "Start thread" | |
begin | |
raise "chatched" | |
rescue => t_ex | |
p message + t_ex.message | |
end | |
puts "End thread" | |
end | |
rescue => ex | |
p ex.message | |
end | |
puts "Waiting for the thread to complete" | |
t.join | |
puts "Test compleated" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment