How can you interrupt a thread that is blocking on IO. I have a thread which is in an infinite loop, which keeps calling ServerSocket.accept(); Interrupting this thread does nothing until it receives a client connection because it is blocked on the accept() method. Any suggestions? Thanks, Brian Podolny
Thanks for the reply but I don't think that solves the problem. The thread is still blocked on the accept(). The stop() method is the right way to shut down but it will not be invoked. Maybe I'm missing something...
Have you tried to use 'setSoTimeout'? It interrupts accept() when timeout expires. Then you can decide if you want to finish or not. Is like an active wait ... but I don't know if there is a better solution. I have never programmed with sockets in Java, but I think it can work ...
That's a good solution Xavier. Thanks. I'm not crazy about the active wait, so I 'll keep thinking on it but if I can't come up with anything than your solution is my way to go.
straws are for suckers. tiny ads are for attractive people.