Skip to content

Instantly share code, notes, and snippets.

@fsvehla
Created June 16, 2009 22:38
Show Gist options
  • Save fsvehla/130952 to your computer and use it in GitHub Desktop.
Save fsvehla/130952 to your computer and use it in GitHub Desktop.
require "thread"
class Mailbox
def initialize
@stop = false
end
def stop!
@stop = true
end
def run
Thread.new {
loop {
# Work...
if @stop
puts "Waaaah"
break
end
}
}
end
end
Signal.trap("INT") {
puts "Wer?"
@mailbox.stop!
}
@mailbox = Mailbox.new
@mailbox.run.join
puts "Teifl gschossen"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment