1 9 package javolution.context; 10 11 import javolution.JavolutionError; 12 13 24 public abstract class ObjectPool { 25 26 29 transient Thread _user; 30 31 34 transient boolean _inUse; 35 36 39 protected ObjectPool() { 40 } 41 42 48 public final Thread getUser() { 49 return _user; 50 } 51 52 64 public final boolean isLocal() { 65 if (_user == Thread.currentThread()) return true; if (!_inUse) throw new JavolutionError( 67 "Access to inner pool or unused pool detected"); 68 if (_user == null) return false; throw new JavolutionError("Concurrent access to local pool detected"); 70 } 71 72 80 public final boolean inUse() { 81 return _inUse; 82 } 83 84 89 public abstract int getSize(); 90 91 97 public abstract void setSize(int size); 98 99 105 public abstract Object next(); 106 107 118 public abstract void recycle(Object obj); 119 120 124 130 protected abstract void recycleAll(); 131 132 135 protected abstract void clearAll(); 136 137 } | Popular Tags |