1 6 package org.logicalcobwebs.proxool; 7 8 import org.apache.commons.logging.Log; 9 import org.apache.commons.logging.LogFactory; 10 11 19 public class HouseKeeperThread extends Thread { 20 21 private static final Log LOG = LogFactory.getLog(HouseKeeperThread.class); 22 23 private boolean stop; 24 25 public HouseKeeperThread(String name) { 26 setDaemon(true); 27 setName(name); 28 } 29 30 public void run() { 31 32 while (!stop) { 33 HouseKeeper hk = HouseKeeperController.getHouseKeeperToRun(); 34 while (hk != null && !stop) { 35 try { 36 hk.sweep(); 40 } catch (ProxoolException e) { 41 LOG.error("Couldn't sweep " + hk.getAlias(), e); 42 } 43 hk = HouseKeeperController.getHouseKeeperToRun(); 44 } 45 try { 46 Thread.sleep(5000); 47 } catch (InterruptedException e) { 48 LOG.error("Interrupted", e); 49 } 50 } 51 52 } 53 54 protected void cancel() { 55 stop = true; 56 } 57 58 } 59 60 61 | Popular Tags |