What is Object Pooling in Java?

An object pool is a collection of a particular object that an application will create and keep on hand for those situations where creating each instance is expensive. A good example would be a database connection or a worker thread. The pool checks instances in and out for users like books out of a library.

Usually object pooling is handled by a Java EE application server. If you need to do it yourself, best to use something like Apache’s object pool. Don’t write one yourself; thread safety and other issues can make it complicated.

Here’s a good reference on weak object references.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)