From: "Iñaki Baz Castillo" Date: 2008-07-21T06:49:38+09:00 Subject: Re: Why Thread.abort_on_exception = yes doesn't show errors? El Domingo, 20 de Julio de 2008, Iñaki Baz Castillo escribió: > El Domingo, 20 de Julio de 2008, Joel VanderWerf escribió: > > You have more control this way, > > but you have to remember to either set abort_on_exception or to wrap > > your thread in a handler or to join the thread later. These are three > > styles, each of which has its place. > > Well, thanks for the explanation but I have a doubt. > > I run a thread "t2" inside thread "t1" but I don't want "t1" to wait to > "t2" to finish, this is: I don't need "t1" joins "t2". > > I also don't want the main program ends because "t2" produces an exception > that nobody handles, but I want to see the error. Is not a way to get this > behaviour? > > The only solution I see is t1 joins t2, is it? Humm, but this is not valid for me, I explain why: I'm using GServer, so it creates a Thread for each incoming TCP connection and runs "serve" method for each one. In "serve" method I parse the TCP incoming data and process it, but I need this connection to remain open and accepting new data even if the received data hasn't be processed yet (it's a SIP server). So, in resume I do: --------------------------------- class GServer # New Thread for a new IO. def serve(io) loop do data = read_IO_incoming_data() Thread.new { Logic::process(data) } end # loop end # def serve end # class GServer ------------------------------- As you see, I need the TCP connection remains open and available ALL the time, I can wait to process the last received data, so I run a Thread and repeat **inmediately** the loop. Also I need that if an exception occurs in Logic::process(data) it being shown but don't stop the programm (abort_on_exception = false). But in this way I can't see the error output if it occurs. How could I get showing the error into the Thread without doing a "join"? (I can't do a join). Thanks a lot for any suggestion. -- Iñaki Baz Castillo