Versions Compared

Key

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

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="59046052efe4f4cd-36bd31da-404645e9-af1894ac-8b9e18ab8944dd2e403e8acd"><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="23acfc950bd07ec6-1fe34411-4079468d-92faaeac-642d89822e9ef6497f16a4e1"><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="dcf4e23a9c6d3939-d72bfb1a-40df47c9-a67381f4-011b19d1be50da4a9c67456b"><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="d51fc484faaec363-095297c1-4a7042d7-be709d41-fc75761bb67d996b854ac576"><ac:plain-text-body><![CDATA[

[[Lee 2009

AA. References#Lee 09]]

Map & Compound Operation

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

...