Guide to Lock Interface in Java

Double Pointer
Tech Wrench
Published in
4 min readJan 14, 2022

--

You can read this article with in-browser code execution of sample programs here.

Don’t forget to buy your copy of Java Concurrency in Practice.

If you are interviewing check out our comprehensive preparation course Java Mulithreading for Engineering Interviews.

Don’t forget to buy your copy of Java Concurrency in Practice. Kindly, consider supporting us on Medium . | Udacity | Coursera | Pluralsight

Explanation

The Lock interface provides a tool for implementing mutual exclusion that is more flexible and capable than synchronized methods and statements. A single thread is allowed to acquire the lock and gain access to a shared resource, however, some implementing classes such as the ReentrantReadWriteLock allow multiple threads concurrent access to shared resource.

Java Multithreading for Senior Engineering Interviews

Learn the ins and out of Java concurrency and multithreading for senior engineering interviews.

The use of synchronized methods or statements provides access to the implicit monitor lock associated with every object, but…

--

--