Resource Pool
Decrease costs of instantiating and maintaining large objects using a pool of pre-generated objects (Figure A-15).
A limited collection of pre-generated objects that can be loaned out and returned.
Used by the pool to generate new instances of a resource or validate a returned resource.
An object that will be loaned out by the pool (Figure A-16).
The client requests objects from the pool, which returns a resource if one is available. If no resources are available, but the pool is not at capacity, a new instance is generated using the factory. If all resources are loaned out, the client waits until one becomes available. When the client has finished using the resource, it returns it to the pool, which uses the factory to validate the returned resource.