Jumping into the object pool
Before we jump into the object pool, let’s look at what an object pool is.
Object pool
An object pool is a collection (pool) of objects that can be reused.
Using object pools is an optimization approach that can positively impact the performance of an application. Instead of recreating objects every time we need them, we pool a collection of objects and simply recycle them. To help understand object pooling, consider a real-world example of a physical library. The library can lend out books (our objects) and return them to the collection (our pool) when the person is done with the book. This allows the library to reissue the book to the next person that needs it. Consider the alternative. If the library destroyed (garbage collection) the book after each use, it would have to create a new one each time it is needed. This would not be efficient.
Database example
A common object pooling implementation in Java programming is with database...