|
GATE Version 3.1-2270 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgate.util.ObjectPool
public class ObjectPool
A generic implementation of pool of references to objects of any kind.
It is thread-safe, so, allows multiple users to get and release objects
"simultaneously". In fact, the standard Java synchronization is used.
The base idea is that, a calling routine will try to get
an object from the pool with method Get. On success, it will use the
object and return it in the pool with the method Put.
If there ares no available objects in the pool, Get will return null.
Then the calling routine should create a new object. Further, scenario goes
in the same way - when finished using the object, calling routine shoud Put
it in the pool for future use, instead of leaving it to be garbage-collected.
The pool initially is empty. The only way to increase the number of objects
managed by the pool, is some external process to Put an object, that was
created, instead of previously Get from the pool.
Pool stores only references to currently "free" or available objects. When
some external routine Gets an object from the pool, its reference is not
locked, it is simply removed from the pool.
Constructor Summary | |
---|---|
ObjectPool(int size)
Constructs and object pool with specified size. |
Method Summary | |
---|---|
Object |
get()
Pulls out an object from the pool. |
boolean |
put(Object o)
Puts an object in the pool, those stating that it's "free" or available for use by another processes and routines. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ObjectPool(int size)
size
- determines the maximum size of the pool. This is the number
free objects that it can manage at the same timeMethod Detail |
---|
public Object get()
public boolean put(Object o)
|
GATE Version 3.1-2270 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |