...
Code Block | ||
---|---|---|
| ||
private final Object lock = new Object();
synchronized(lock) { /* */ }
|
Note that the instance of the raw object should not be changed from within the synchronized block. For example, creating and storing the reference of a new object into the lock
field.
Noncompliant Code Example
...