Created
June 16, 2009 22:38
-
-
Save fsvehla/130952 to your computer and use it in GitHub Desktop.
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
| 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