...
Code Block | ||
---|---|---|
| ||
List<Widget> widgetList = new ArrayList<Widget>(); pubicpublic void widgetOperation() { // May throw ConcurrentModificationException for (Widget w : widgetList) { doSomething(w); } } |
...
Code Block | ||
---|---|---|
| ||
List<Widget> widgetList = Collections.synchronizedList(new ArrayList<Widget>()); pubicpublic void widgetOperation() { for (Widget w : widgetList) { doSomething(w); } } |
...
Code Block | ||
---|---|---|
| ||
List<Widget> widgetList = new ArrayList<Widget>(); pubicpublic void widgetOperation() { List<Widget> deepCopy = new ArrayList<Widget>(); synchronized (widgetList) { // Client-side locking for (Object obj : widgetList) { deepCopy.add(obj.clone()); } } for (Widget w : deepCopy) { doSomething(w); } } |
...
Code Block | ||
---|---|---|
| ||
List<Widget> widgetList = new CopyOnWriteArrayList<Widget>(); pubicpublic void widgetOperation() { for (Widget w : widgetList) { doSomething(w); } } |
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="2ba4046a39aba7b7-5af0a246-41f545e9-b16d8daa-2b08f3a0b609d7cee054f40c"><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="9f4c597885177b4b-405d0c44-41ca4ff9-af249c89-038d4bd9f74ea47e47e4eefc"><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="16f1cc02dfe3c636-88228562-42df46d8-91f1bd6b-dc736ecdf64c7739e69a63e0"><ac:plain-text-body><![CDATA[ | [[Goetz 2006 | AA. Bibliography#Goetz 06]] | 5.1.2. Iterators and Concurrentmodificationexception | ]]></ac:plain-text-body></ac:structured-macro> |
...