One of the best-known examples of a full-fledged object pool is the JDBC connection pool. Main reasons:
- objects in the pool are expensive to create and relate with external resources
- each object in the pool is served to at most one client a time
- objects in the pool need to be brought back to a clean state before being served again to a new client
With the above in mind, can the Java Integer cache be regarded as a object pool realization? Here is why I doubt it:
- objects in the pool can be used by more than one client a time due to their immutability
- immutability also prevents pool objects from reaching a stale state
- there's no notion of a "free" object, ready to be allocated to a client