@Override
 public void run() {
   try {
     while (!Thread.currentThread().isInterrupted()) {
       onFrozenLock.lock();
       try {
         Message message = received.take();
         if (message instanceof RequestMessage) process(((RequestMessage) message));
         else if (message instanceof ResponseMessage) process(((ResponseMessage) message));
       } finally {
         onFrozenLock.unlock();
       }
     }
   } catch (InterruptedException e) {
     Thread.currentThread().interrupt();
   }
 }
  /**
   * Same as <tt>sendAndExpect</tt>, but in case of no answer returns empty Optional instead of
   * throwing exception
   */
  public <ReplyType extends ResponseMessage> Optional<ReplyType> sendAndWait(
      InetSocketAddress address,
      RequestMessage<ReplyType> message,
      DispatchType type,
      int timeout) {
    try {
      //noinspection unchecked
      ReplyType response =
          (ReplyType) submit(address, message, type).poll(timeout, TimeUnit.MILLISECONDS);

      return Optional.ofNullable(response);
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      return Optional.empty();
    }
  }