title: Interrupt a thread in DatagramSocket.receive
body: <p>I'm building an application that listens on both TCP and UDP, and I've run into some trouble with my shutdown mechanism. When I call <code>Thread.interrupt()</code> on each of the listening threads, the TCP thread is interrupted from listening, whereas the UDP listener isn't. To be specific, the TCP thread uses <code>ServerSocket.accept()</code>, which simply returns (without actually connecting). Whereas the UDP thread uses <code>DatagramSocket.receive()</code>, and doesn't exit that method.</p>
  
  <p>Is this an issue in my JRE, my OS, or should I just switch to <code>(Datagram)Socket.close()</code>?</p>
  
  <p>UPDATE: I've found an <a href="http://www.thatsjava.com/java-essentials/14879/" rel="noreferrer">analysis</a> of the problem. It confirms that the behavior is not consistent.</p>