public static synchronized int methodA() { ... }
Public access
Class (not instance) method
Returns int
Synchronized on the class: only one
thread at a time can use this method or any other method or block that is also synchronized on the same class.
public static int methodB() { ... }
Public access
Class method
Returns int
Not synchronized - several threads may execute this method simultaneously
public synchronized int methodC() { ... }
Public, returns int
Instance method
Synchronized on the object instance. Only one thread at a time may use this method or any other method or block that is also synchronized on
the same object instance
public int methodD() { ... }
Public, returns int, instance method, not synchronized.