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 ...

Dealing With Multiple Data Sources in EJB3 2

There are some situations in which we need to take a connection from other data sources different from that which our EJB is using.  like: Check is the method defined in an EJB, so it is in transactional scope and in this we are trying to get a connection from another data source. Now this ...

Implementing hash function and using it into Own implemented HashMap

First what is a hash function? A hash function is a function which maps keys to indices of an array. So if k is the key and we have an array of size 10, then h(k) will be some integer value ranging between 0 to 9. So this means the hash function h maps the ...

Making a cluster with Infinispan and JGroups 5

Recently i did a POC on infinispan and JGroups and submitted this POC in my company. I think it is worth to share on blog. First a little about infinispan. Infinispan is an open source data grid platform. It exposes a JSR-107 compatible Cache interface (which in turn extends java.util.Map) in which you can store ...