From: Derek Lewis Date: 2003-12-13T01:22:36+09:00 Subject: Re: threads and io I think the problem here is that you're getting some sort of exception raised inside the thread (possibly a connection refused), and aren't seeing it. I would suggest putting this at the top of your program: Thread.abort_on_exception=true And see what sort of error you get. Without that, if there's an exception in your thread that isn't rescued, your thread will silently die. On Fri, 12 Dec 2003, JB wrote: > I have soe problems whitn treads and I/O. > > My program starts severals threads that open tcp connections. > The main thread waits the user to press Q to stop the program. > > It seems that the gets fonction blocks all my threads !!! > How is it possible? > What did I wrong? > > Thanks alot. > > there is my programm > > require 'socket' > > #parametrers > $host = $*[0] > $port = $*[1] > $number = $*[2] > $number = 1 if ($number == nil) > $number = $number.to_i > > #start threads > threads = [] > for i in 1..($number) > threads << Thread.new(i) { |i| > sleep (rand(10)) > while(1) > t = TCPSocket.new($host,$port) > sleep (rand(10)) > t.close > sleep (rand(10)) > end > } > end > > print "Q to quit\n" > while(!($stdin.gets =~ /Q.*/)) > end > > > Derek Lewis =================================================================== Java Web-Application Developer Email : email@lewisd.com Cellular : 604.312.2846 Website : http://www.lewisd.com "If you've got a 5000-line JSP page that has "all in one" support for three input forms and four follow-up screens, all controlled by "if" statements in scriptlets, well ... please don't show it to me :-). Its almost dinner time, and I don't want to lose my appetite :-)." - Craig R. McClanahan