Skip to content

Instantly share code, notes, and snippets.

@joevandyk
Created August 19, 2014 23:15
Show Gist options
  • Save joevandyk/4bdbf5a7a713575a761f to your computer and use it in GitHub Desktop.
Save joevandyk/4bdbf5a7a713575a761f to your computer and use it in GitHub Desktop.
def foo
t = Thread.new do
begin
sleep 1
puts "finished thread"
rescue
puts "exception raised"
ensure
puts "ensure called"
end
end
end
thread = foo
sleep 0.1
puts "killing thread"
foo.kill
sleep 3
killing thread
ensure called
finished thread
ensure called
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment