001 package org.maltparser.core.pool;
002
003 import org.maltparser.core.exception.MaltChainedException;
004
005 public abstract class ObjectPool<T> {
006 protected int keepThreshold;
007
008 public ObjectPool() {
009 this(Integer.MAX_VALUE);
010 }
011
012 public ObjectPool(int keepThreshold) {
013 setKeepThreshold(keepThreshold);
014 }
015
016 public int getKeepThreshold() {
017 return keepThreshold;
018 }
019
020 public void setKeepThreshold(int keepThreshold) {
021 this.keepThreshold = keepThreshold;
022 }
023
024 protected abstract T create() throws MaltChainedException;
025 public abstract void resetObject(T o) throws MaltChainedException;
026 public abstract T checkOut() throws MaltChainedException;
027 public abstract void checkIn(T o) throws MaltChainedException;
028 public abstract void checkInAll() throws MaltChainedException;
029 }