void placeResponse(final int sequence, final ProtocolFrame response) {
   synchronized (myResponseQueue) {
     if (response == null || myResponseQueue.containsKey(sequence)) {
       myResponseQueue.put(sequence, response);
     }
     if (response != null) {
       myResponseQueue.notifyAll();
     }
   }
 }
  @Nullable
  ProtocolFrame waitForResponse(final int sequence) {
    ProtocolFrame response;
    long until = System.currentTimeMillis() + RESPONSE_TIMEOUT;

    synchronized (myResponseQueue) {
      do {
        try {
          myResponseQueue.wait(1000);
        } catch (InterruptedException ignore) {
        }
        response = myResponseQueue.get(sequence);
      } while (response == null && isConnected() && System.currentTimeMillis() < until);
      myResponseQueue.remove(sequence);
    }

    return response;
  }
 public RemoteDebugger getDebugger(String threadId) {
   return myThreadIdToDebugger.get(threadId);
 }
 public void register(String id, RemoteDebugger debugger) {
   myThreadIdToDebugger.put(id, debugger);
 }
 @Override
 public Collection<PyThreadInfo> getThreads() {
   return Collections.unmodifiableCollection(new ArrayList<PyThreadInfo>(myThreads.values()));
 }
 private void cleanUp() {
   myThreads.clear();
   myResponseQueue.clear();
   mySequence = -1;
   myTempVars.clear();
 }