01: /*
02: * This software is released under a licence similar to the Apache Software Licence.
03: * See org.logicalcobwebs.proxool.package.html for details.
04: * The latest version is available at http://proxool.sourceforge.net
05: */
06: package org.logicalcobwebs.proxool;
07:
08: import org.apache.commons.logging.Log;
09: import org.apache.commons.logging.LogFactory;
10:
11: /**
12: * Responsible for running {@link HouseKeeper#sweep sweep}
13: *
14: * @version $Revision: 1.5 $, $Date: 2006/01/18 14:40:01 $
15: * @author bill
16: * @author $Author: billhorsman $ (current maintainer)
17: * @since Proxool 0.8
18: */
19: public class HouseKeeperThread extends Thread {
20:
21: private static final Log LOG = LogFactory
22: .getLog(HouseKeeperThread.class);
23:
24: private boolean stop;
25:
26: public HouseKeeperThread(String name) {
27: setDaemon(true);
28: setName(name);
29: }
30:
31: public void run() {
32:
33: while (!stop) {
34: HouseKeeper hk = HouseKeeperController
35: .getHouseKeeperToRun();
36: while (hk != null && !stop) {
37: try {
38: // if (LOG.isDebugEnabled()) {
39: // LOG.debug("About to sweep " + hk.getAlias());
40: // }
41: hk.sweep();
42: } catch (ProxoolException e) {
43: LOG.error("Couldn't sweep " + hk.getAlias(), e);
44: }
45: hk = HouseKeeperController.getHouseKeeperToRun();
46: }
47: try {
48: Thread.sleep(5000);
49: } catch (InterruptedException e) {
50: LOG.error("Interrupted", e);
51: }
52: }
53:
54: }
55:
56: protected void cancel() {
57: stop = true;
58: }
59:
60: }
61:
62: /*
63: Revision history:
64: $Log: HouseKeeperThread.java,v $
65: Revision 1.5 2006/01/18 14:40:01 billhorsman
66: Unbundled Jakarta's Commons Logging.
67:
68: Revision 1.4 2004/03/26 15:58:56 billhorsman
69: Fixes to ensure that house keeper and prototyper threads finish after shutdown.
70:
71: Revision 1.3 2003/04/19 12:57:29 billhorsman
72: removed redundant debug
73:
74: Revision 1.2 2003/03/10 15:26:47 billhorsman
75: refactoringn of concurrency stuff (and some import
76: optimisation)
77:
78: Revision 1.1 2003/03/05 18:42:33 billhorsman
79: big refactor of prototyping and house keeping to
80: drastically reduce the number of threads when using
81: many pools
82:
83: */
|