Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Wiki Markup
Reliance on {{ConcurrentModificationException}} is insufficient to stop side effects resulting from modifying an underlying Collection while simultaneously iterating over the collection. The fail-fast behavior may occur only after processing an arbitrary number of elements. In _Java Concurrency In Practice_ \[[Goetz 2006|AA. Bibliography#Goetz 06]\], GöetzGoetz et al. note "\[Fail-fast iterators\] are implemented by associating a modification count with the collection: if the modification count changes during iteration, {{hasNext}} or {{next}} throws {{ConcurrentModificationException}}. However, this check is done without synchronization, so there is a risk of seeing a stale value of the modification count and therefore that the iterator does not realize a modification has been made. This was a deliberate design tradeoff to reduce the performance impact of the concurrent modification detection code."

...

This noncompliant code example (based on a SDN 2008 bug report 6687277) uses the Collection's remove() method to remove an element from an ArrayList while iterating over the ArrayList. The resulting behavior is unspecified.

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="cba9693087316354-b010aa8f-489c4a36-bf5f8c6c-d17f4ed8bc8d54b1da0bae9b"><ac:plain-text-body><![CDATA[

[[API 2006

AA. Bibliography#API 06]]

Class [ConcurrentModificationException

http://java.sun.com/j2se/1.5.0/docs/api/java/util/ConcurrentModificationException.html]

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="6ae2a01139fa4f25-21e99475-41404223-a2708899-f85d84088a7f4210c3637313"><ac:plain-text-body><![CDATA[

[[SDN 2008

AA. Bibliography#SDN 08]]

[Sun Bug database, Bug ID:6687277

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6687277]

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="748107a2d05bf48d-a8d97faa-4cf24c8a-9ba28a40-975bff485f4a47638233f6b8"><ac:plain-text-body><![CDATA[

[[Goetz 2006

AA. Bibliography#Goetz 06]]

5.1.2. Iterators and Concurrentmodificationexception

]]></ac:plain-text-body></ac:structured-macro>

...