T - Type of pool objectspublic class ObjectPool<T> extends Object
| Modifier and Type | Field and Description |
|---|---|
static long |
TTL_UNLIMITED |
| Constructor and Description |
|---|
ObjectPool(boolean concurrent,
IPoolMethods<T> impl)
extended constructor.
|
ObjectPool(boolean concurrent,
IPoolMethods<T> impl,
int initialSize)
extended constructor.
|
ObjectPool(boolean concurrent,
IPoolMethods<T> impl,
Lock lock)
extended constructor.
|
ObjectPool(boolean concurrent,
IPoolMethods<T> impl,
Lock lock,
int initialSize)
extended constructor.
|
ObjectPool(IPoolMethods<T> impl)
Constructor with
IPoolMethods implementation param. |
ObjectPool(IPoolMethods<T> impl,
int initialSize)
Constructor with
IPoolMethods implementation param
NOT threadsafe |
| Modifier and Type | Method and Description |
|---|---|
void |
flushPool()
Remove all inactive (unlocked) objects from pool.
|
T |
get()
Internal method to obtain an object from the pool.
|
Lock |
getLock() |
int |
getPoolSize()
Returns the current number of objects in the pool.
|
int |
getUnlockedCount()
Returns the number of objects in the pool that are available.
|
void |
giveBack(T obj)
Release the object in pool.
|
void |
setLock(Lock lock)
Set an lock.
|
public static final long TTL_UNLIMITED
public ObjectPool(IPoolMethods<T> impl)
IPoolMethods implementation param.
NOT threadsafeimpl - - IPoolMethodspublic ObjectPool(IPoolMethods<T> impl, int initialSize)
IPoolMethods implementation param
NOT threadsafeimpl - - IPoolMethodsinitialSize - - Initial size of the pools. On startup, this number of objects will be created.public ObjectPool(boolean concurrent,
IPoolMethods<T> impl)
concurrent - - if true pool can handle concurrencyimpl - - IPoolMethodspublic ObjectPool(boolean concurrent,
IPoolMethods<T> impl,
int initialSize)
concurrent - - if true pool can handle concurrencyimpl - - IPoolMethodsinitialSize - - Initial size of the pools. On startup, this number of objects will be createdpublic ObjectPool(boolean concurrent,
IPoolMethods<T> impl,
Lock lock)
concurrent - - if true pool can handle concurrencyimpl - - IPoolMethodslock - - Lock to setpublic ObjectPool(boolean concurrent,
IPoolMethods<T> impl,
Lock lock,
int initialSize)
concurrent - - if true pool can handle concurrencyimpl - - IPoolMethodslock - - Lock to setinitialSize - - Initial size of the pools. On startup, this number of objects will be createdpublic Lock getLock()
public void setLock(Lock lock)
lock - - Lock to setNullPointerException - - if lock is null (use NullLock)NullLockpublic T get()
public void giveBack(T obj)
obj - - object in poolpublic int getPoolSize()
public int getUnlockedCount()
public void flushPool()
Copyright © 2024. All rights reserved.