Skip to content

Files

Latest commit

 

History

History
19 lines (12 loc) · 631 Bytes

SynchronizedMethod.md

File metadata and controls

19 lines (12 loc) · 631 Bytes

Pattern: Synchronized method

Issue: -

Description

This rule reports uses of the synchronized keyword on methods. Synchronized methods are the same as synchronizing on this, which effectively make your synchronization policy public and modifiable by other objects. To avoid possibilities of deadlock, it is better to synchronize on internal objects.

Here is an example of code that produces a violation:

synchronized def someMethod() {
    // do stuff ...
}

Further Reading