Instances of classes that implement either or both of the Lock and Condition interfaces of the java.util.concurrent.locks package are known as high-level concurrency objects. Using the intrinsic locks of such objects is a questionable practice even in cases where the code may appear to function correctly. Consequently, programs that interact with such objects must use only the high-level locking facilities provided by the interfaces; use of the intrinsic locks is prohibited. This problem generally arises when code is refactored from intrinsic locking to the java.util.concurrent dynamic-locking utilities.
Noncompliant Code Example (ReentrantLock
...
)
The doSomething() method in this noncompliant code example synchronizes on the intrinsic lock of an instance of ReentrantLock rather than on the reentrant mutual exclusion Lock encapsulated by ReentrantLock.
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="f87ed099778a972f-828f61fa-4dbe45a7-8fb89e5d-c691af8833ce1fbfa1e68d73"><ac:plain-text-body><![CDATA[ | [[API 2006 | AA. Bibliography#API 06]] |
| ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="8d317317ab2179de-844cfc07-4cdb427b-b88caa77-0ebb3f2bef055a86c0721dfc"><ac:plain-text-body><![CDATA[ | [[Findbugs 2008 | AA. Bibliography#Findbugs 08]] |
| ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="90250eb704d870a6-b22b645d-47cd4a72-9060b45c-d0e148af9fe6ac01eb536ebb"><ac:plain-text-body><![CDATA[ | [[Pugh 2008 | AA. Bibliography#Pugh 08]] | Synchronization | ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="2781776908fdd328-235815eb-48aa46fb-8609bb9c-4a8f2757e73c5b0c940af269"><ac:plain-text-body><![CDATA[ | [[Miller 2009 | AA. Bibliography#Miller 09]] | Locking | ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="49adc1cb5228f288-b13ced7b-45244735-b7dfbbd5-0e3bb495a5889a8ac690580b"><ac:plain-text-body><![CDATA[ | [[Tutorials 2008 | AA. Bibliography#Tutorials 08]] | [Wrapper Implementations | http://java.sun.com/docs/books/tutorial/collections/implementations/wrapper.html] | ]]></ac:plain-text-body></ac:structured-macro> |
...