#107 Improve JavaDoc for Object Pool example
This commit is contained in:
parent
2bc23844a4
commit
86c68f96e3
@ -5,21 +5,25 @@ package com.iluwatar.object.pool;
|
|||||||
* When it is necessary to work with a large number of objects that are particularly expensive to instantiate
|
* When it is necessary to work with a large number of objects that are particularly expensive to instantiate
|
||||||
* and each object is only needed for a short period of time, the performance of an entire application may be
|
* and each object is only needed for a short period of time, the performance of an entire application may be
|
||||||
* adversely affected. An object pool design pattern may be deemed desirable in cases such as these.
|
* adversely affected. An object pool design pattern may be deemed desirable in cases such as these.
|
||||||
*
|
* <p>
|
||||||
* The object pool design pattern creates a set of objects that may be reused. When a new object is needed, it
|
* The object pool design pattern creates a set of objects that may be reused. When a new object is needed, it
|
||||||
* is requested from the pool. If a previously prepared object is available it is returned immediately, avoiding
|
* is requested from the pool. If a previously prepared object is available it is returned immediately, avoiding
|
||||||
* the instantiation cost. If no objects are present in the pool, a new item is created and returned. When the
|
* the instantiation cost. If no objects are present in the pool, a new item is created and returned. When the
|
||||||
* object has been used and is no longer needed, it is returned to the pool, allowing it to be used again in the
|
* object has been used and is no longer needed, it is returned to the pool, allowing it to be used again in the
|
||||||
* future without repeating the computationally expensive instantiation process. It is important to note that
|
* future without repeating the computationally expensive instantiation process. It is important to note that
|
||||||
* once an object has been used and returned, existing references will become invalid.
|
* once an object has been used and returned, existing references will become invalid.
|
||||||
*
|
* <p>
|
||||||
* In this example we have created OliphauntPool inheriting from generic ObjectPool. Oliphaunts can be checked
|
* In this example we have created {@link OliphauntPool} inheriting from generic {@link ObjectPool}. {@link Oliphaunt}s can be checked
|
||||||
* out from the pool and later returned to it. The pool tracks created instances and their status (available,
|
* out from the pool and later returned to it. The pool tracks created instances and their status (available,
|
||||||
* inUse).
|
* inUse).
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Program entry point
|
||||||
|
* @param args command line args
|
||||||
|
*/
|
||||||
public static void main( String[] args ) {
|
public static void main( String[] args ) {
|
||||||
OliphauntPool pool = new OliphauntPool();
|
OliphauntPool pool = new OliphauntPool();
|
||||||
System.out.println(pool);
|
System.out.println(pool);
|
||||||
|
@ -4,6 +4,11 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import com.iluwatar.object.pool.App;
|
import com.iluwatar.object.pool.App;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Application test
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class AppTest {
|
public class AppTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user