Lock interface was introduced in Java 1.5 and is generally used as a synchronization mechanism to provide important operations for blocking.
Advantages of using Lock interface over Synchronization block :
* Methods of Lock interface i.e., Lock() and Unlock() can be called in different methods. It is the main advantage of a lock interface over a synchronized block because the synchronized block is fully contained in a single method.
* Lock interface is more flexible and makes sure that the longest waiting thread gets a fair chance for execution, unlike the synchronization block.