Last active
December 31, 2015 13:39
-
-
Save mrkplt/7994678 to your computer and use it in GitHub Desktop.
Same as https://gist.github.com/mrkplt/7993228 except it spins up threads to do things in.
This file contains 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
@hello = 'Hello' | |
puts Process.pid | |
thread_array = Array.new | |
thread_array << Thread.new do | |
Signal.trap('USR1'){ | |
@hello = 'HALLO!' | |
} | |
Signal.trap('USR2'){ | |
@hello = 'Hello' | |
} | |
Signal.trap('INT'){ | |
puts "\n#{thread_array.size}" | |
print 'Exiting...' | |
exit | |
} | |
end | |
thread_array << Thread.new do | |
while true | |
print @hello | |
sleep 1 | |
end | |
end | |
thread_array.each {|t| t.join} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment