A consistent locking policy guarantees that multiple threads cannot simultaneously access or modify shared data. When two or more operations must be performed as a single atomic operation, a consistent locking policy must be implemented using either intrinsic synchronization or java.util.concurrent
utilities. In the absence of such a policy, the code is susceptible to race conditions.
Given an invariant involving multiple objects, a programmer might incorrectly assume that a group of individually atomic operations is When presented with a set of operations, where each is guaranteed to be atomic, it is tempting to assume that a single operation consisting of individually-atomic operations is guaranteed to be 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.
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="23398e3767ce8f95-0d138a5f-4e0e455a-aa8d8285-3214cdc6595e5fe994fea7d5"><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="ff3e53e03d15d4a4-3dc8af39-47384be4-bc5c8a34-d1f72fa7808ff3794dcc13f4"><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="83924fe7041f8b4a-c176b84c-4afd4b54-85369bfc-45c4d45f72b25b35605d3887"><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="9c6f852ed13838cd-c365cfc0-40a44c3d-ac46bbee-b616455cd4400b110f3f6416"><ac:plain-text-body><![CDATA[ | [[Lee 2009 | AA. References#Lee 09]] | Map & Compound Operation | ]]></ac:plain-text-body></ac:structured-macro> |
...