Skip to content

Instantly share code, notes, and snippets.

@mindscratch
Created May 8, 2012 16:26
Show Gist options
  • Select an option

  • Save mindscratch/2636967 to your computer and use it in GitHub Desktop.

Select an option

Save mindscratch/2636967 to your computer and use it in GitHub Desktop.
simple ruby threading example
%W(INT TRAP).each do |sig|
trap(sig) do
puts "caught: #{sig}"
raise "get outta here"
end
end
x = Thread.new {
(1..5).each do
puts "working"
sleep 1.0
end
}
x.join
puts "all done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment