At 22:35 30.05.2002 -0700, [EMAIL PROTECTED] wrote: > > It's a good book by the way. If the Thread.interrupt method gives an > > Computer Science professor and an expert in the field such hard time, I > > don't think we should attempt to be "smart". Thread.interrupt is not > > needed. Nice and simple. End of story. > > > > Just remove the "watchdogThread.interrupt();" statement and your code > > will continue to run just as well. > >Hm. I don't think I have a race condition here.
You are not using any wait or notify calls, so, yes, no race conditions. > I am just trying to wake up a sleeping thread so the watchdog can > shutdown faster. If you have set the interval to 60 seconds, it could > be up to a minute before the watchdog wakes up and figures out it > should shutdown. How can/should I do this differently? Yes, it could take 60 seconds for the watchDog thread to exit. So? :-) You do not have to do anything different, except removing the "watchdogThread.interrupt()" statement. >Also, you'll notice that I do not use interrupt() for the SocketWatchdog. >Experience has shown that the interrupt() call does NOT cause the >ServerSocket.accept() to interrupt itself (contrary to the first link you >sent). At least not in JDK 1.3. As I said in a previous note, interrupt() never does anything useful except causing confusion. So interrupt() not interrupting socket.accept() is not surprising. Does anyone know of a good article explaining why the interrupt() method should be shunned? >That is why I set the SoTimeout property >to 2 seconds. So, it could take up to 2 seconds for a SocketWatchdog to >shutdown completely. That could be a problem if as part of watchdogs being >allowed in configuration files, the new watchdog being configured wants to >use the same port number. It could be up to 2 seconds before the port is >free from the original watchdog. Maybe watchdogs should not return from the >stopWatchdog() method until the watchdog is completely shutdown. One strategy for dealing with lingering ports is to try again. Try to open a port, if that fails, sleep for 30 seconds and try again. Give up if the second try also fails. >thanks, >-Mark -- Ceki SUICIDE BOMBING - A CRIME AGAINST HUMANITY Sign the petition: http://www.petitiononline.com/1234567b I am signatory number 22106. What is your number? -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>