An object pool is a creation pattern where, if the operation of creating an object is complex and time-consuming we can use Object Pool. A common application of Object Pool which applications use in general is with database connections. On application initialization, it pre-creates a set of objects and keeps them alive in a collection. Whenever there is a need, the authoritative manager assigns one object to the client and allows it to use. Once used, the object’s is not being destroyed but returned to the pool. Periodically the validity of an object is being checked by routines. If the object is not reusable, it gets destroyed and again the authoritative pool manager decides to create new objects based on the configuration/requirement by the client.
One needs to take care of the following scenarios:
> A limited number of resources in a pool
> When new resource creation fails.
> Expiry of resources
Posted Date:- 2021-09-06 20:49:04