1 22 package org.jboss.resource.connectionmanager; 23 24 import java.util.LinkedList ; 25 26 34 public class PoolFiller implements Runnable 35 { 36 private final LinkedList pools = new LinkedList (); 37 38 private final Thread fillerThread; 39 40 private static final PoolFiller filler = new PoolFiller(); 41 42 public static void fillPool(InternalManagedConnectionPool mcp) 43 { 44 filler.internalFillPool(mcp); 45 } 46 47 public PoolFiller () 48 { 49 fillerThread = new Thread (this, "JCA PoolFiller"); 50 fillerThread.start(); 51 } 52 53 public void run() 54 { 55 ClassLoader myClassLoader = getClass().getClassLoader(); 56 Thread.currentThread().setContextClassLoader(myClassLoader); 57 while (true) 59 { 60 try 61 { 62 InternalManagedConnectionPool mcp = null; 63 while (true) 65 { 66 67 synchronized (pools) 68 { 69 mcp = (InternalManagedConnectionPool)pools.removeFirst(); 70 } 71 if (mcp == null) 72 break; 73 74 mcp.fillToMin(); 75 } 76 } 77 catch (Exception e) 78 { 79 } 80 81 try 82 { 83 synchronized (pools) 84 { 85 pools.wait(); 86 } 87 } 88 catch (InterruptedException ie) 89 { 90 return; 91 } 92 } 93 } 94 95 private void internalFillPool(InternalManagedConnectionPool mcp) 96 { 97 synchronized (pools) 98 { 99 pools.addLast(mcp); 100 pools.notify(); 101 } 102 } 103 } 104 | Popular Tags |