





























































































使用 copyOnWriteArrayList時 ,通過 list.remove()方法是安全的 但是使用iterator.remove是會拋異常的
查看copyOnWriteArrayList源碼 會發現 iterator.remove方法的實現是直接拋異常的
/**
* Not supported. Always throws UnsupportedOperationException.
* @throws UnsupportedOperationException always; <tt>remove</tt>
* is not supported by this iterator.
*/
public void remove() {
throw new UnsupportedOperationException();
}
但是通過ArrayList實現時, list.remove會拋異常 java.util.ConcurrentModificationException,
但是 ArrayList的 iterator.remove不會拋異常