Skip to content

Instantly share code, notes, and snippets.

@jjb
Created September 16, 2012 00:19
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 jjb/3730517 to your computer and use it in GitHub Desktop.
Save jjb/3730517 to your computer and use it in GitHub Desktop.
Ruby Thread#raise raises at wherever the thread happens to be
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
➔ 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