Borrows an object from the pool.
If there is an idle instance available in the pool, then either the most-recently returned (if {@link #getLifo() lifo} == true) or "oldest" (lifo == false) instance sitting idle in the poolwill be activated and returned. If activation fails, or {@link #getTestOnBorrow() testOnBorrow} is setto true and validation fails, the instance is destroyed and the next available instance is examined. This continues until either a valid instance is returned or there are no more idle instances available.
If there are no idle instances available in the pool, behavior depends on the {@link #getMaxActive() maxActive}and (if applicable) {@link #getWhenExhaustedAction() whenExhaustedAction} and {@link #getMaxWait() maxWait}properties. If the number of instances checked out from the pool is less than maxActive,
a new instance is created, activated and (if applicable) validated and returned to the caller.
If the pool is exhausted (no available idle instances and no capacity to create new ones), this method will either block ( {@link #WHEN_EXHAUSTED_BLOCK}), throw a NoSuchElementException
( {@link #WHEN_EXHAUSTED_FAIL}), or grow ( {@link #WHEN_EXHAUSTED_GROW} - ignoring maxActive).The length of time that this method will block when whenExhaustedAction == WHEN_EXHAUSTED_BLOCK
is determined by the {@link #getMaxWait() maxWait} property.
When the pool is exhausted, multiple calling threads may be simultaneously blocked waiting for instances to become available. As of pool 1.5, a "fairness" algorithm has been implemented to ensure that threads receive available instances in request arrival order.
@return object instance @throws NoSuchElementException if an instance cannot be returned
|
|
|
|
|
|
|
|
|
|