R
- The type of the resources managed by this pool.X
- The type of the exceptions thrown by this pool.public interface Pool<R,X extends Exception>
Implementations must be thread-safe. However, this does not necessarily apply to the implementation of its managed resources.
Modifier and Type | Interface and Description |
---|---|
static interface |
Pool.Releasable<X extends Exception>
This interface is designed to be used with Pools which enable their
resources to release itself.
|
Modifier and Type | Method and Description |
---|---|
R |
allocate()
Allocates a resource from this pool.
|
void |
release(R resource)
Releases a previously allocated resource to this pool.
|
R allocate() throws X extends Exception
Mind that a pool implementation should not hold references to its allocated resources because this could cause a memory leak.
void release(R resource) throws X extends Exception
resource
- a resource.IllegalArgumentException
- if the given resource has not been
allocated by this pool and the implementation cannot tolerate
this.X
- if releasing the resource fails for any other reason.X extends Exception
Copyright © 2005–2018 Schlichtherle IT Services. All rights reserved.