Semaphore

Java Concurrency

Java Semaphore vs ReentrantLock

Learn what a Semaphore and a Reentrant Lock are along with practical examples. We will also explore some of the main differences between the two and the use cases where we can use these while working in a multithreaded application. 1. What is a Semaphore? A Semaphore is a Thread synchronization construct that acts as …

Java Binary Semaphore (+Example)

A binary semaphore is a synchronization primitive that can hold only two values, typically 0 and 1. We use binary semaphore to manage access to a shared resource by multiple threads in a concurrent environment. Conceptually, a binary semaphore can be thought of as a lock that allows only one …

Throttling Task Submission Rate in Java

1. Introduction In BlockingQueue and ThreadPoolExecutor example, we learned creating a CustomThreadPoolExecutor which had the following capabilities: Tasks are being submitted to the blocking queue. An executor picks up the task from the queue and execute them. It had overridden beforeExecute() and afterExecute() methods to perform pre-and-post activities if needed. …

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.