Wiki Markup |
---|
Code that uses synchronization can sometimes be enigmatic and tricky to debug. Misuse of synchronization primitives is a common source of implementation errors. An analysis of the JDK 1.6.0 source code unveiled at least 31 bugs that fell into this category. \[[Pugh 08|AA. Java References#Pugh 08]\] |
...
Code Block | ||
---|---|---|
| ||
final Lock lock = new ReentrantLock(); public void doSomething() { lock.lock(); try { // ... } finally { lock.unlock(); } } |
It is recommended to not use the intrinsic locks of objects of classes that implement Lock
or Condition
interfaces. If there is no real need of using the advanced functionality of the dynamic locking utilities of package java.util.concurrent
, prefer using the Executor
framework or other concurrency primitives such as synchronization and atomic classes.
...
Noncompliant Code Example | Message |
---|---|
| No obvious issues |
Boxed primitive | No obvious issues |
interned | No obvious issues |
String literal | No data available about field accesses |
| No data available about field accesses |
| No obvious issues |
Collection view | No obvious issues |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
...