Every object has an intrinsic lock associated with it. Synchronization enforces exclusive access to an object's state and establishes happens-before relationships that are essential to visibility. A thread has to acquire the object's intrinsic lock before accessing exclusive and consistent access to object's fields .A synchronized method acquires a monitor before it executes.
Since a static method has no associated object, what happens when a thread calls a static synchronized method?
The JVM creates a Class object when the class is loaded (used for the first time). Once a class is loaded into a JVM, the same class will not be loaded again. The JVM creates one instance of java.lang.Class for each class that is loaded. It is the java.lang.Class instance whose lock is used to protect the static methods of the class (if they're synchronized).
Remember:For a class (static) method, the monitor associated with the Class object for the method's class is used. For an instance method, the monitor associated with this (the object for which the method was invoked) is used.
Using synchronized keyword with a static method, ensures that one and only one thread can access operate on that method. Therefore threads calling static synchronized methods in the same class will always block each other—they all lock on the same Class instance.
Example of static method synchronization :
public static synchronized int getCount() {
return count;
}