Semaphore
Class Semaphore
- java.lang.Object
-
- java.util.concurrent.Semaphore
- All Implemented Interfaces:
- Serializable
public class Semaphore extends Object implements Serializable
A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each acquire()
blocks if necessary until a permit is available, and then takes it. Each release()
adds a permit, potentially releasing a blocking acquirer. However, no actual permit objects are used; the Semaphore
just keeps a count of the number available and acts accordingly.
Semaphores are often used to restrict the number of threads