gate.util.ObjectPool Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gate-core Show documentation
Show all versions of gate-core Show documentation
GATE - general achitecture for text engineering - is open source
software capable of solving almost any text processing problem. This
artifact enables you to embed the core GATE Embedded with its essential
dependencies. You will able to use the GATE Embedded API and load and
store GATE XML documents. This artifact is the perfect dependency for
CREOLE plugins or for applications that need to customize the GATE
dependencies due to confict with their own dependencies or for lower
footprint.
The newest version!
/*
* Copyright (c) 1995-2012, The University of Sheffield. See the file
* COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
*
* This file is part of GATE (see http://gate.ac.uk/), and is free
* software, licenced under the GNU Library General Public License,
* Version 2, June 1991 (in the distribution as file licence.html,
* and also available at http://gate.ac.uk/gate/licence.html).
*
* Atanas Kiryakov, 01/02/2002
*
* $Id: ObjectPool.java 17600 2014-03-08 18:47:11Z markagreenwood $
*/
package gate.util;
import java.util.Vector;
/**
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.
*/
public class ObjectPool {
private Vector