title: Close sockets of JeroMQ-Worker in MultiThreaded Execution
body: <p>consider the following worker:</p>
  
  <pre><code>public class Worker implements Callable&lt;String&gt; ....
  // initialize context
  @Override
  public String call() {
      ZMQ.Socket pullSocket = context.socket(ZMQ.PULL);
      pullSocket.connect(HOST_PULL_SOCKET);
  
      while (!Thread.currentThread().isInterrupted() &amp;&amp; !context.isClosed()) {
  
          String result = pullSocket.recvStr();
          return result;
      }
  
      return "test";
  }
  </code></pre>
  
  <p>The <code>pullSocket.recvStr()</code> throws an <code>java.nio.channels.ClosedByInterruptException</code> as the following scenario</p>
  
  <pre><code>ExecutorService service = Executors.newFixedThreadPool(4);
  List&lt;Worker&gt; workers = new ArrayList&lt;&gt;();
  for(int i = 0: i &lt; 4;i++){
      workers.add(new Worker()); // Class where call() is executed
  }
  String result = service.invokeAny(workers);
  </code></pre>
  
  <p>is executed.</p>
  
  <p>How can I avoid this kind of Exception or what is preferred way to handle the closing of sockets when<code>invokeAny()</code> gets called?</p>