How to terminate a server socket thread on timeout? <p>I'm using <code>Spring Integration</code> on the server side to offer a socket. The socket as a defined <code>soTimeout</code>, so that exceeding that timeout will close the current open socket connection to the client.</p> <pre><code>TcpConnectionFactoryFactoryBean fact = new TcpConnectionFactoryFactoryBean(); fact.setSoTimeout(timeout); </code></pre> <p>But the thread on the server side will continue. How can I force cancelation/termination of the server socket as well (maybe with an additional thread timeout, so that no thread can hang in the background by any issues)?</p>