Thread Archive

Java Exchanger example

Exchanger class is introduced with java 1.5 with other classes such ConcurrentHashMap, CountDownLatch, Semaphores. Exchanger class is used to exchange object between two threads. Exchanger simply waits until two separate threads calls exchange method, when …

Java newCachedThreadPool Example

In this tutorial, we will learn about Executor’s¬†newCachedThreadPool factory method. In the last tutorial, I have shared introduction to ThreadPoolExecutor. If you are not aware of concepts of ThreadPoolExecutor, you should go through that first. …

Java ThreadPoolExecutor example

Java 5 has introduced new concurrent API called “Executor frameworks” to make programmer life easy. It simplifies design and development of multi-thread applications. It consists of mainly Executor, ExecutorService interface and ThreadPoolExecutor class which implements …

Java Semaphore example

In this tutorial, we are going to see about Semaphore in java. Semaphore is a class in java.util.concurrent package introduced in JDK 5. Semaphore basically maintains a set of permits, so there are two methods …