Inspectopedia
 
2024.3

Synchronization on local variable or method parameter

Warning
New
Last modified: 03 December 2024

Reports synchronization on a local variable or parameter.

It is very difficult to guarantee correct operation when such synchronization is used. It may be possible to improve such code, for example, by controlling access using a synchronized wrapper class or by synchronizing on a field.

Example: