Code example for ConcurrentModificationException

0
 
    @Override 
    public synchronized boolean onMove(final int oldPosition, final int newPosition) {
        if (inIteration) {
            if (!iterating) {
                throw new ConcurrentModificationException();
            } 
        } 
        else { 
            iterating = false;
        } 
        return super.onMove(oldPosition, newPosition);
    } 
 
    private class CursorIterator implements Iterator<T> {
        public CursorIterator() { 
        } 
 
        public boolean hasNext() { 
            return !isAfterLast();
        }