Created
May 8, 2012 16:26
-
-
Save mindscratch/2636967 to your computer and use it in GitHub Desktop.
simple ruby threading example
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
| %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