package org.jboss.resource.connectionmanager;
import java.util.LinkedList;
public class PoolFiller implements Runnable
{
private final LinkedList pools = new LinkedList();
private final Thread fillerThread;
private static final PoolFiller filler = new PoolFiller();
public static void fillPool(InternalManagedConnectionPool mcp)
{
filler.internalFillPool(mcp);
}
public PoolFiller ()
{
fillerThread = new Thread(this, "JCA PoolFiller");
fillerThread.start();
}
public void run()
{
ClassLoader myClassLoader = getClass().getClassLoader();
Thread.currentThread().setContextClassLoader(myClassLoader);
while (true)
{
try
{
InternalManagedConnectionPool mcp = null;
while (true)
{
synchronized (pools)
{
mcp = (InternalManagedConnectionPool)pools.removeFirst();
}
if (mcp == null)
{
break;
}
mcp.fillToMin();
}
}
catch (Exception e)
{ }
try
{
synchronized (pools)
{
pools.wait();
}
}
catch (InterruptedException ie)
{
return;
} } }
private void internalFillPool(InternalManagedConnectionPool mcp)
{
synchronized (pools)
{
pools.addLast(mcp);
pools.notify();
}
}
}