...
Given an invariant involving multiple objects, a programmer might incorrectly assume that a group of individually atomic operations is collectively atomic without additional locking. Similarly, programmers might incorrectly assume that use of a thread-safe Collection
is sufficient to preserve an invariant that involves the collection's elements without additional synchronization. A thread-safe class can only guarantee atomicity of its individual methods. A grouping of calls to such methods requires additional synchronization for the group.
Consider, for example, a scenario where the standard thread-safe API lacks a single method to both find a particular person's record in a Hashtable
and also update that person's payroll information. In such cases, the two method invocations must be performed atomically.
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="88c2569fd20c63af-9a35ab5d-45404668-9ad6ab1e-7e6a1ff418f8b8a82ec29e86"><ac:plain-text-body><![CDATA[ | [[API 2006 | AA. References#API 06]] |
| ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="6d72508aa25aebf6-dba8b19d-49454701-ab11be8e-fb118b5b75b17786f46151a8"><ac:plain-text-body><![CDATA[ | [[Goetz 2006 | AA. References#Goetz 06]] | Section 4.4.1, Client-side Locking | ]]></ac:plain-text-body></ac:structured-macro> |
| Section 5.2.1, ConcurrentHashMap | |||
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="a5211e8732d8139c-c4ded26a-4fed4009-ab2385c0-3b5cf2f87e188dcb79b82cf0"><ac:plain-text-body><![CDATA[ | [[JavaThreads 2004 | AA. References#JavaThreads 04]] | Section 8.2, Synchronization and Collection Classes | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="f9630f41c16e81e2-4cd47513-487e47b1-ba4e9e9d-babe7d1098336aff963c6afa"><ac:plain-text-body><![CDATA[ | [[Lee 2009 | AA. References#Lee 09]] | Map & Compound Operation | ]]></ac:plain-text-body></ac:structured-macro> |
...