istack common utility code 2.6.1-redhat-2

com.sun.istack
Class Pool.Impl<T>

java.lang.Object
  extended by com.sun.istack.Pool.Impl<T>
All Implemented Interfaces:
Pool<T>
Enclosing interface:
Pool<T>

public abstract static class Pool.Impl<T>
extends Object
implements Pool<T>

Default implementation that uses ConcurrentLinkedQueue as the data store.

Note for Implementors

Don't rely on the fact that this class extends from ConcurrentLinkedQueue.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.sun.istack.Pool
Pool.Impl<T>
 
Constructor Summary
Pool.Impl()
           
 
Method Summary
protected abstract  T create()
          Creates a new instance of object.
 void recycle(T t)
          Returns an object back to the pool.
 T take()
          Gets a new object from the pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pool.Impl

public Pool.Impl()
Method Detail

take

@NotNull
public final T take()
Gets a new object from the pool.

If no object is available in the pool, this method creates a new one.

Specified by:
take in interface Pool<T>
Returns:
always non-null.

recycle

public final void recycle(T t)
Returns an object back to the pool.

Specified by:
recycle in interface Pool<T>

create

@NotNull
protected abstract T create()
Creates a new instance of object.

This method is used when someone wants to take an object from an empty pool.

Also note that multiple threads may call this method concurrently.


istack common utility code 2.6.1-redhat-2

Copyright © 2012 JBoss by Red Hat. All Rights Reserved.