...
Using a private lock may only be achieved with block synchronization, as method synchronization always uses the object's intrinsic lock. However, block . Block synchronization is also preferred over method synchronization, because it is easy to move operations out of the synchronized block when they might take a long time and they are not truly a critical sectionoperations that do not require synchronization can be moved outside the synchronized region which reduces the overall execution time.
Noncompliant Code Example
...