PoolUtils synchronizedPooledFactory

In this post under Apache Pool, I will show with example how to create a synchronized object pool factory. Below is the complete main class for your reference Main class package package17; import org.apache.commons.pool2.PoolUtils; import org.apache.commons.pool2.PooledObjectFactory; public class StringBufferPoolExample17 { public static void main(String[] args) { StringBufferPooledObjectFactory stringBufferPooledObjectFactory = new StringBufferPooledObjectFactory(); PooledObjectFactory<StringBuffer> threadSafePooledObjectFactory = PoolUtils.synchronizedPooledFactory(stringBufferPooledObjectFactory);…… Continue reading PoolUtils synchronizedPooledFactory

PoolUtils synchronizedPool

In this post under Apache Pool, I will show with example how to create a synchronized object pool. Below is the complete main class for your reference Main class package package16; import org.apache.commons.pool2.ObjectPool; import org.apache.commons.pool2.PoolUtils; import org.apache.commons.pool2.impl.GenericObjectPool; public class StringBufferPoolExample16 { public static void main(String[] args) { GenericObjectPool<StringBuffer> genericObjectPool = new GenericObjectPool<StringBuffer>(new StringBufferPooledObjectFactory()); ObjectPool<StringBuffer> threadSafeGenericObjectPool…… Continue reading PoolUtils synchronizedPool

MaxWait duration property

In this post under Apache Pool, I will explain with example the purpose of “MaxWait” duration property. This property is used in conjunction with “BlockWhenExhausted” property explained in previous post. This property works only when “BlockWhenExhausted” is set to “true”. When “BlockWhenExhausted” is set to true and the caller tries to get idle objects more…… Continue reading MaxWait duration property

Object Pool addObject method example

In this post under Apache Pool, I will explain with example the purpose of “addObject” method in Apache Pool. In Apache Pool we can create three types of object Pool1) GenericObjectPool2) GenericKeyedObjectPool3) SoftReferenceObjectPool All these classes support “addObject” method. Now lets understand the purpose of this method. If you refer to all my previous post,…… Continue reading Object Pool addObject method example