예제 #1
0
 /**
  * Retrieves the first available object in the pool or returns null if none are available.
  *
  * @return T
  * @throws Exception
  */
 public T request() throws Exception {
   T t = queue.poll();
   if (t != null) {
     if (generator != null) generator.enable(t);
   }
   return t;
 }
예제 #2
0
 /**
  * Retrieves the first available object in the pool or creates a new instance if there are none
  * available.
  *
  * @return T
  */
 public T get() {
   T t = queue.poll();
   if (t == null) {
     t = newInstance();
   }
   if (generator != null) generator.enable(t);
   return t;
 }