Author: ryan
Date: Mon Mar 23 19:15:39 2009
New Revision: 757510
URL: http://svn.apache.org/viewvc?rev=757510&view=rev
Log:
checking to see if the queue should finish differently
Modified:
incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/impl/MultiThreadedTaskMaster.java
Modified:
incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/impl/MultiThreadedTaskMaster.java
URL:
http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/impl/MultiThreadedTaskMaster.java?rev=757510&r1=757509&r2=757510&view=diff
==============================================================================
---
incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/impl/MultiThreadedTaskMaster.java
(original)
+++
incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/impl/MultiThreadedTaskMaster.java
Mon Mar 23 19:15:39 2009
@@ -117,7 +117,17 @@
terminate();
}
else {
- startWorkers();
+ int cnt = startWorkers();
+
+ // shutdown the queue...
+ if( cnt == 0 && !queue.hasNext() ) {
+ if( pool.getActiveCount() > 1 ) {
+ // keep running
+ }
+ else {
+ terminate();
+ }
+ }
}
}
}
@@ -141,12 +151,12 @@
* Will start a new worker.
* @return the id of the worker we just started.
*/
- private void startWorkers(){
+ private int startWorkers(){
int cnt = 0;
try {
while( queue.hasNext() && cnt++ < maxThreads ) {
- // checking the "activeCount" can be expensive...
+// // checking the "activeCount" can be expensive...
// // The getActiveCount is often wrong for only a single thread!
// // the javadocs say the number is approxiate, so in the case we only
// // see one active worker, we will assume there are none...
@@ -161,12 +171,13 @@
}
}
catch( RejectedExecutionException ex ) {
- log.info( "humm", ex );
+ log.trace( "rejected", ex );
}
- if( cnt == 0 && !queue.hasNext() ) {
- terminate(); // nothing to do, we must be done...
- }
+// if( cnt == 0 && !queue.hasNext() && pool.getActiveCount() == 0 ) {
+// terminate(); // nothing to do, we must be done...
+// }
+ return cnt;
}