|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
E - is the templated type of the elements in the pool.public interface Pool<E>
This is the interface for a simple pool. It allows to borrow an object from the pool. If that object is NOT needed anymore, it
should be released.
A typical pool implementation will have an internal buffer to cache
released objects so they can be reused for further
requests. Such buffer should be limited to a maximum size
(capacity). While that size is reached, released
objects will NOT be cached anymore (and the garbage collector should free
them).
ATTENTION:
Do NOT use this interface for a Thread-pool. There is already
Executor for this use-case (see
Executors).
| Method Summary | |
|---|---|
E |
borrow()
This method borrows an element from this pool. |
boolean |
isEmpty()
This method determines if the pool is empty. |
void |
release(E element)
This method releases the given element. |
| Method Detail |
|---|
E borrow()
release it.empty, a new instance is created for
you. Otherwise a existing instance (that has been released before) will be returned so it can be reused.
null. This may only happen if explicitly documented by
the chosen implementation.void release(E element)
element. It will be put back
into the pool.element
is NOT in use anymore. Therefore no reference should exist on the
element and you should NOT have passed the
element to a third-party library that may keep it in some
cache.
element - is the element to add to the pool.Collection.add(Object)boolean isEmpty()
true if the pool is empty.Collection.isEmpty()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||