Helper class for crating pools of objects. An example use looks like this:
public class MyPooledClass {
private static final SynchronizedPool sPool =
new SynchronizedPool(10);
public static MyPooledClass obtain() {
MyPooledClass instance = sPool.acquire();
return (instance != null) ? instance : new MyPooledClass();
}
public void recycle() {
// Clear state if needed.
sPool.release(this);
}
. . .
}
|