title: How can I interrupt a ServerSocket accept() method?
body: <p>In my main thread I have a <code>while(listening)</code> loop which calls <code>accept()</code> on my <code>ServerSocket</code> object, then starts a new client thread and adds it to a Collection when a new client is accepted.</p>
  <p>I also have an Admin thread which I want to use to issue commands, like <code>'exit'</code>, which will cause all the client threads to be shut down, shut itself down, and shut down the main thread, by turning listening to false.</p>
  <p>However, the <code>accept()</code> call in the <code>while(listening)</code> loop blocks, and there doesn't seem to be any way to interrupt it, so the while condition cannot be checked again and the program cannot exit!</p>
  <p>Is there a better way to do this? Or some way to interrupt the blocking method?</p>