Created
September 16, 2012 00:19
-
-
Save jjb/3730517 to your computer and use it in GitHub Desktop.
Ruby Thread#raise raises at wherever the thread happens to be
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
require 'thread' | |
t = Thread.new{ | |
sleep 0.1 | |
sleep 0.1 | |
sleep 0.1 | |
sleep 0.1 | |
sleep 0.1 | |
} | |
sleep rand(4) * 0.1 | |
t.raise | |
t.join |
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
➔ ruby thread_raise.rb | |
thread_raise.rb:6:in `sleep': unhandled exception | |
from thread_raise.rb:6:in `block in <main>' | |
➔ ruby thread_raise.rb | |
thread_raise.rb:7:in `sleep': unhandled exception | |
from thread_raise.rb:7:in `block in <main>' | |
➔ ruby thread_raise.rb | |
thread_raise.rb:5:in `sleep': unhandled exception | |
from thread_raise.rb:5:in `block in <main>' | |
➔ ruby thread_raise.rb | |
thread_raise.rb:5:in `sleep': unhandled exception | |
from thread_raise.rb:5:in `block in <main>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment