Wiki Markup |
---|
According to the Java API documentation \[[API 2006|AA. Bibliography#APIReferences#API 06]\] for the {{Iterator.remove()}} method: |
...
Wiki Markup |
---|
According to the Java API documentation \[[API 2006|AA. Bibliography#APIReferences#API 06]\] for {{ConcurrentModificationException}}: |
...
Wiki Markup |
---|
Reliance on {{ConcurrentModificationException}} is inadequate to prevent undefined behavior 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#GoetzReferences#Goetz 06]\], Goetz and colleagues note: |
...
Wiki Markup |
---|
This approach must be implemented correctly to avoid starvation, deadlock, and scalability issues \[[Goetz 2006|AA. Bibliography#GoetzReferences#Goetz 06]\]. |
Compliant Solution (Deep Copying)
...
Wiki Markup |
---|
Creating deep copies of the list prevents underlying changes in the original list from affecting the iteration in progress. "Since the clone is thread-confined, no other thread can modify it during iteration, eliminating the possibility of {{ConcurrentModificationException}}. (The collection still must be locked during the clone operation itself)" \[[Goetz 2006a|AA. Bibliography#GoetzReferences#Goetz 06]\]. However, this approach is often more expensive than other techniques. There is also a risk of operating on stale data, which may affect the correctness of the code. |
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="5343505221368a69-75cd6303-4ee44c6d-afba80a0-86d0fd69326b3877a16ef381"><ac:plain-text-body><![CDATA[ | [[API 2006 | AA. Bibliography#API References#API 06]] | Class [ | 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="4a6b2093de4810f7-67880db8-4fcf434c-8a809d76-6b3fc89e930c1c75c23eac4c"><ac:plain-text-body><![CDATA[ | [[SDN 2008 | AA. Bibliography#SDN References#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="c6ada6641ca58b0c-7f2d72de-4ffb4c43-a698b2b5-d8bfe03a477f96ae8b4c604a"><ac:plain-text-body><![CDATA[ | [[Goetz 2006 | AA. Bibliography#Goetz References#Goetz 06]] | 5.1.2. Iterators and | ]]></ac:plain-text-body></ac:structured-macro> |
...