// synchronized
sclass MoreEfficientCopyOnWriteList<A> extends NotifyingList<A> {
  bool hasIterator;
  
  *() { this(new L); }
  
  // Note: uses list as the inner list!
  *(L<A> list) { super(list); }
  
  public synchronized Iterator<A> iterator() {
    set hasIterator;
    ret super.iterator();
  }
  
  public synchronized Spliterator<A> spliterator() {
    set hasIterator;
    ret super.spliterator();
  }
  
  public synchronized ListIterator<A> listIterator() {
    set hasIterator;
    ret super.listIterator();
  }

  public synchronized ListIterator<A> listIterator(int index) {
    set hasIterator;
    ret super.listIterator(index);
  }
  
  @Override
  // This is called in synchronized block
  void beforeChange {
    if (hasIterator) {
      setInnerList(cloneList(list));
      hasIterator = false;
    }
  }
  
  void change {}
}