What is the difference between a synchronized method and a synchronized block?

Technology CommunityCategory: JavaWhat is the difference between a synchronized method and a synchronized block?
VietMX Staff asked 3 years ago

In Java programming, each object has a lock. A thread can acquire the lock for an object by using the synchronized keyword. The synchronized keyword can be applied in a method level (coarse grained lock) or block level of code (fine grained lock).