Monitoring a Lock interface

A Lock interface is one of the basic mechanisms provided by the Java concurrency API to get the synchronization of a block of code. It allows the definition of a critical section. A critical section is a block of code that accesses a shared resource and can't be executed by more than one thread at the same time. This mechanism is implemented by the Lock interface and the ReentrantLock class.

In this recipe, you will learn what information you can obtain about a Lock object and how to obtain that information.

Getting ready

The example of this recipe has been implemented using the Eclipse IDE. If you use Eclipse or other IDE such as NetBeans, open it and create a new Java project.

How to do it...

Follow these steps to implement ...

Get Java 7 Concurrency Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.