Author: toad
Date: 2007-08-11 19:28:23 +0000 (Sat, 11 Aug 2007)
New Revision: 14626

Modified:
   trunk/freenet/src/freenet/node/NodeStats.java
   trunk/freenet/src/freenet/support/Executor.java
   trunk/freenet/src/freenet/support/PooledExecutor.java
Log:
Don't take threads which are waiting for work into account when enforcing 
thread limit

Modified: trunk/freenet/src/freenet/node/NodeStats.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeStats.java       2007-08-11 19:23:10 UTC 
(rev 14625)
+++ trunk/freenet/src/freenet/node/NodeStats.java       2007-08-11 19:28:23 UTC 
(rev 14626)
@@ -673,7 +673,7 @@


        public int getActiveThreadCount() {
-               return rootThreadGroup.activeCount();
+               return rootThreadGroup.activeCount() - 
node.executor.waitingThreads();
        }

        public int getThreadLimit() {

Modified: trunk/freenet/src/freenet/support/Executor.java
===================================================================
--- trunk/freenet/src/freenet/support/Executor.java     2007-08-11 19:23:10 UTC 
(rev 14625)
+++ trunk/freenet/src/freenet/support/Executor.java     2007-08-11 19:28:23 UTC 
(rev 14626)
@@ -11,4 +11,6 @@
        /** Execute a job. */
        public void execute(Runnable job, String jobName);

+       /** Count the number of threads waiting for work */
+       public int waitingThreads();
 }

Modified: trunk/freenet/src/freenet/support/PooledExecutor.java
===================================================================
--- trunk/freenet/src/freenet/support/PooledExecutor.java       2007-08-11 
19:23:10 UTC (rev 14625)
+++ trunk/freenet/src/freenet/support/PooledExecutor.java       2007-08-11 
19:28:23 UTC (rev 14626)
@@ -54,6 +54,10 @@
                }
        }

+       public synchronized int waitingThreads() {
+               return waitingThreads.size();
+       }
+       
        class MyThread extends Thread {

                final String defaultName;


Reply via email to