Created
January 18, 2011 17:31
-
-
Save brixen/784801 to your computer and use it in GitHub Desktop.
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
require 'socket' | |
def say(*args) | |
STDOUT.puts *args | |
STDOUT.flush | |
end | |
Thread.abort_on_exception = true | |
s1 = TCPServer.new("127.0.0.1", 9000) | |
say "Before s1#accept" | |
s1_t = Thread.new do | |
begin | |
s1.accept | |
rescue Exception => err | |
say "s1#accept raised #{err.inspect}" | |
end | |
end | |
say "After s1#accept thread block" | |
say "Sleeping for 10 seconds" | |
sleep 10 | |
say "Closing s1" | |
s1.close | |
say "Waiting for s1 thread to join()" | |
s1_t.join | |
say "s1 thread joined" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment