E - is the templated type of the elements in the pool.public interface Pool<E>
borrow an object from the pool. If that
object is NOT needed anymore, it should be released. 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). Thread-pool. There is already Executor for this
use-case (see Executors).| Modifier and Type | Method and Description |
|---|---|
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. |
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()Copyright © 2001–2016 mmm-Team. All rights reserved.