void (final ResponseReader<? extends R> reader) { ApplicationManager.getApplication().executeOnPooledThread(() -> { myThread = Thread.currentThread(); try { while (true) { final R r = reader.readResponse(); if (r == null) break; if (r instanceof ResponseToRequest) { final int requestId = ((ResponseToRequest)r).getRequestId(); processResponse(requestId, r); } else { processResponse(r); } } } catch (InterruptedException ignored) { } catch (IOException e) { LOG.info(e); } finally { synchronized (myLock) { myStopped = true; } } }); }