A keyed pool pools instances of multiple types. Each
type may be accessed using an arbitrary key.
Example of use:
Object obj = null;
Object key = "Key";
try {
obj = pool.borrowObject(key);
//...use the object...
} catch(Exception e) {
//...handle any exceptions...
} finally {
// make sure the object is returned to the pool
if(null != obj) {
pool.returnObject(key,obj);
}
}
KeyedObjectPool implementations may choose to store at most
one instance per key value, or may choose to maintain a pool of instances
for each key (essentially creating a Map of
pools ).
A keyed pool pools instances of multiple types. Each type may be accessed using an arbitrary key.
Example of use:
Object obj = null; Object key = "Key"; try { obj = pool.borrowObject(key); //...use the object... } catch(Exception e) { //...handle any exceptions... } finally { // make sure the object is returned to the pool if(null != obj) { pool.returnObject(key,obj); } }KeyedObjectPool implementations may choose to store at most one instance per key value, or may choose to maintain a pool of instances for each key (essentially creating a Map of pools ).