In Java 1.4+, there\'re 3 ways to interrupt a stream which is blocked on socket I/O:
1) Since the underlying OS call error that rasies the exception comes from a TCP stack that is multithread aware, there should not be any problem.
2) Not sure- have not tried it, but would be surprised if there was any issue.
3) There may be some performance differences. An OS close() call requires a 4-way handshake with the TCP peer - not sure which OS support that in a non-blocking manner, (same with connect).
4) Thread..or socket. You have to keep a reference to something. Since you are closing the socket, it seems reasonable to keep a reference to it :)