Class Level Synchronization in Java

Synchronization in java works in two ways, one is Object Level Synchronization and other one is Class Level Synchronization. Class level synchronization requires a Class level lock and Object Level Synchronization requires an Object level lock.

Class Level lock can be achieved by using two keywords static and synchronized in any method signature. But Object level lock can be achieved by using synchronized keyword or block, there can be multiple Objects for a particular class but only one class will be available for any Java application with unique name.

Java Class Level Synchronization example