...
The locking strategy of classes designed for inheritance should always be documented. This information can subsequently be used to determine an appropriate locking strategy for subclasses (see rule rules LCK00-J. Use private final lock objects to synchronize classes that may interact with untrusted code and LCK11-J. Avoid client-side locking when using classes that do not commit to their locking strategy).
Noncompliant Code Example (Synchronized Method)
...
| Code Block | ||
|---|---|---|
| ||
class Base {
public synchronized void doSomething() {
// ...
}
}
class Derived extends Base {
@Override public synchronized void doSomething() {
// ...
}
}
|
This compliant solution also complies with rule LCK00-J. Use private final lock objects to synchronize classes that may interact with untrusted code because the accessibility of the class is package-private. That type of accessibility is permitted when untrusted code cannot infiltrate the package.
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="407c65918c0fffc0-e35ace33-467e42a4-89abb95d-80a1a80f7f6910aa50739b48"><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="6fedf020c1d574cb-9c3787c9-4ea54a2f-ac479566-b09a5e15b1a85350c98433e3"><ac:plain-text-body><![CDATA[ | [[SDN 2008 | AA. Bibliography#SDN 08]] | Sun bug database, [Bug ID 4294756 | http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4294756] | ]]></ac:plain-text-body></ac:structured-macro> |
...