public void consumeResponse(OmwListResponse<T> response) {
synchronized (response.getResultList()) { // XXX this isn't synchronized safely
for (T t : response.getResultList()) {
if (!cacheList.contains(t)) {
cacheList.add(t);
}
}
}
}
The the situation is I don't want anyone to chance response.getResultList() or cacheList until this method is done. How do I properly do this?
Create a lock object:
private static final void LOCK = new Object();
and synchronize on that.