UOSM - Use Of the 'synchronized' Modifier

The 'synchronized' modifier on methods can sometimes cause confusion during maintenance and debugging. This rule recommends to avoid using this modifier and encourages using 'synchronized' statements instead.

Wrong

class UOSM {
    public synchronized void method () {
        // do something
    }
}

Tip: Use synchronized statements instead of synchronized methods.

Right

class UOSM {
    public void method () {
       synchronized(this) {
            // do something
       }
    }
}