KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > logicalcobwebs > proxool > HouseKeeperThread


1 /*
2  * This software is released under a licence similar to the Apache Software Licence.
3  * See org.logicalcobwebs.proxool.package.html for details.
4  * The latest version is available at http://proxool.sourceforge.net
5  */

6 package org.logicalcobwebs.proxool;
7
8 import org.apache.commons.logging.Log;
9 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 JavaDoc {
20
21     private static final Log LOG = LogFactory.getLog(HouseKeeperThread.class);
22
23     private boolean stop;
24
25     public HouseKeeperThread(String JavaDoc 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 // if (LOG.isDebugEnabled()) {
37
// LOG.debug("About to sweep " + hk.getAlias());
38
// }
39
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 JavaDoc e) {
48                 LOG.error("Interrupted", e);
49             }
50         }
51
52     }
53
54     protected void cancel() {
55         stop = true;
56     }
57
58 }
59
60
61 /*
62  Revision history:
63  $Log: HouseKeeperThread.java,v $
64  Revision 1.5 2006/01/18 14:40:01 billhorsman
65  Unbundled Jakarta's Commons Logging.
66
67  Revision 1.4 2004/03/26 15:58:56 billhorsman
68  Fixes to ensure that house keeper and prototyper threads finish after shutdown.
69
70  Revision 1.3 2003/04/19 12:57:29 billhorsman
71  removed redundant debug
72
73  Revision 1.2 2003/03/10 15:26:47 billhorsman
74  refactoringn of concurrency stuff (and some import
75  optimisation)
76
77  Revision 1.1 2003/03/05 18:42:33 billhorsman
78  big refactor of prototyping and house keeping to
79  drastically reduce the number of threads when using
80  many pools
81
82  */
Popular Tags