The following method throws a ConcurrentModificationException because the list it iterates over gets modified. Can I use synchronised to lock... something... either while the list is modified or iterated over?
How would I go about doing that? I've tried a few ways but none of them seem to work. Locking "this" doesn't work, for instance.
public class Deck extends ArrayList<Card> {
...
public void render(Canvas canvas) {
for (Card card : this) {
// Do stuff
}
}
...
}