Package org.mycore.util.concurrent
Class MCRPool<T>
java.lang.Object
org.mycore.util.concurrent.MCRPool<T>
- Type Parameters:
T
-
A MCRPool allows thread safe pooling of thread unsafe objects.
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
MCRPool
Creates an MCRPool of the given size- Parameters:
size
- capacity of the poolsupplier
- return values foracquire()
, called not more than size times
-
-
Method Details
-
acquire
Acquires a value from the pool. The caller has to make sure that any instance returned is released afterwards.- Throws:
InterruptedException
- if interrupted while waiting
-
release
Puts the resource back into the pool.
-