|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object org.thymeleaf.util.ResourcePool<T>
public final class ResourcePool<T>
Represents a limited set or pool of resources, which needs to be used with exclusive ownership.
Should be used in a similar fashion to the following so that resources are always released properly:
MyResource resource = myLimitedResource.allocate(); try { // actual code using the resource } finally { myLimitedResource.release(resource); }
Constructor Summary | |
---|---|
ResourcePool(java.util.Collection<T> resources)
|
Method Summary | |
---|---|
T |
allocate()
Allocates and returns a resource from the pool. |
void |
release(T resource)
Releases a previously allocated resource. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ResourcePool(java.util.Collection<T> resources)
Method Detail |
---|
public T allocate()
Allocates and returns a resource from the pool.
Blocks until a resource is available when a resource is not available immediately.
public void release(T resource)
Releases a previously allocated resource.
Might also be used to introduce new resources, e.g. in place of a broken resource.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |