|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlejos.util.Recycler
public abstract class Recycler
An abstract object recycler. This class should
be extended to define the createInstance
method for a particular kind of Recyclable
.
On concrete recycler instances, invoke
allocate()
to create objects
and recycle()
to release them.
It is the programmer's responsibility to
avoid using objects that have been recycled.
Note that the caller is expected to provide thread safety for instances of this class.
Recyclable
Constructor Summary | |
---|---|
Recycler()
Constructs a recycler. |
Method Summary | |
---|---|
Recyclable |
allocate()
Attempts to obtain a free object. |
protected abstract Recyclable |
createInstance()
This is a factory method that should be overridden to create an Recyclable object instance. |
void |
recycle(Recyclable r)
Reclaims a Recyclable previously allocated with the allocate method. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait |
Constructor Detail |
---|
public Recycler()
Method Detail |
---|
public final Recyclable allocate()
public final void recycle(Recyclable r)
allocate
method.
The release
method of the Recyclable object
is invoked here.
protected abstract Recyclable createInstance()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |