Java / Java Multithreading
What is Lock interface in Java Concurrency API?
A lock is a thread synchronization mechanism like synchronized blocks that are sophisticated than Java's synchronized blocks. From Java 5 the package java.util.concurrent.locks contains several lock implementations.
The advantages of using locks are,
- implements fairness.
- possible to try to acquire the lock and backout immediately or after a timeout if the lock cannot be acquired.
- possible to acquire and release locks in different scopes in any order.
More Related questions...