public final class Pools extends Object
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);
}
. . .
}
| Modifier and Type | Class and Description |
|---|---|
static interface |
Pools.Pool<T>
Interface for managing a pool of objects.
|
static class |
Pools.SimplePool<T>
Simple (non-synchronized) pool of objects.
|
static class |
Pools.SynchronizedPool<T>
Synchronized) pool of objects.
|
Copyright © 2015. All rights reserved.