CyclicBarrier And CountDownLatch in JAVA

According to java doc Cyclic Barrier is: A synchronization aid that allows a set of threads to all wait for each other to reach a common barrier point. CyclicBarriers are useful in programs involving a fixed sized party of threads that must occasionally wait for each other. Now why this barrier is called cyclic: The ...

Implementing Own Thread Pool in Java

Lets Implement own Thread Pool in Java. Lets first make a class which will be having two methods enqueue and dequeue. This class will act as a blocking queue on the dequeue method i.e. a blocking call so that we will only return when the queue has something on it, otherwise wait until something is ...

Implementing Producer-Consumer by making own implementation of blocking queue.

Lets implement Producer, Consumer by making own implementation of blocking queue. Lets make own interface which will be having two methods: 1. enqueue // for put 2. dequeue // for take Here is our interface: Now lets make one implementation of above interface. Above implementation behaves as blocking queue, i.e. according to javadoc: ” A ...