public void registerResponse(String s) { String id = s.split(":")[0].trim(); for (int i = 0; i < queries.size(); i++) { Query q = queries.get(i); if (q.id.equals(id)) { q.setResponse(s.replace(id + ":", "")); queries.remove(q); } } }
public String makeQuery(String s) { Query q = new Query(s); queries.add(q); try { q.join(); } catch (InterruptedException e) { e.printStackTrace(); } return q.response; }