How to use Counting Semaphore in Concurrent Java Application? Example Tutorial
Counting Semaphore in Java is a synchronizer that allows imposing a bound on the resource is added in Java 5 along with other popular concurrent utilities like CountDownLatch, CyclicBarrier, and Exchanger, etc. Counting Semaphore in Java maintains a specified number of pass or permits, In order to access a shared resource, Current Thread must acquire a permit. If a permit is already exhausted by other threads than it can wait until a permit is available due to the release of permits from different threads. This concurrency utility can be very useful to implement a producer-consumer design pattern or implement bounded pool or resources like Thread Pool, DB Connection pool, etc.
تعليقات
إرسال تعليق