Implementing Semaphore

Learn how to design and implement a simple semaphore class in Java.

We'll cover the following...

Problem Statement

Java does provide its own implementation of Semaphore, however, Java's semaphore is initialized with an initial number of permits, rather than the maximum possible permits and the developer is expected to take care of always releasing the intended number of maximum permits.

Briefly, a semaphore is a construct that allows some threads to access a fixed set of resources ...