Skip to content

Instantly share code, notes, and snippets.

@mrkplt
Last active December 31, 2015 13:39
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 mrkplt/7994678 to your computer and use it in GitHub Desktop.
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.
@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