cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1360677 - /cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
Date Thu, 12 Jul 2012 13:47:43 GMT
Author: dkulp
Date: Thu Jul 12 13:47:43 2012
New Revision: 1360677

URL: http://svn.apache.org/viewvc?rev=1360677&view=rev
Log:
Merged revisions 1360406 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1360406 | dkulp | 2012-07-11 17:15:48 -0400 (Wed, 11 Jul 2012) | 3 lines

  If another thread is working on adding threads, just return and let it
  handle it.

........

Modified:
    cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java

Modified: cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java?rev=1360677&r1=1360676&r2=1360677&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
(original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
Thu Jul 12 13:47:43 2012
@@ -71,7 +71,7 @@ public class AutomaticWorkQueueImpl impl
     
     AWQThreadFactory threadFactory;
     ReentrantLock mainLock;
-    
+    final ReentrantLock addThreadLock = new ReentrantLock();
     
     DelayQueue<DelayedTaskWrapper> delayQueue;
     WatchDog watchDog;
@@ -440,20 +440,25 @@ public class AutomaticWorkQueueImpl impl
         ex.execute(r);
         if (addWorkerMethod != null 
             && !ex.getQueue().isEmpty() 
-            && this.approxThreadCount < highWaterMark) {
-            mainLock.lock();
+            && this.approxThreadCount < highWaterMark
+            && addThreadLock.tryLock()) {
             try {
-                int ps = this.getPoolSize();
-                int sz = executor.getQueue().size();
-                int sz2 = this.getActiveCount();
-                
-                if ((sz + sz2) > ps) {
-                    ReflectionUtil.setAccessible(addWorkerMethod).invoke(executor, addWorkerArgs);
+                mainLock.lock();
+                try {
+                    int ps = this.getPoolSize();
+                    int sz = executor.getQueue().size();
+                    int sz2 = this.getActiveCount();
+                    
+                    if ((sz + sz2) > ps) {
+                        ReflectionUtil.setAccessible(addWorkerMethod).invoke(executor, addWorkerArgs);
+                    }
+                } catch (Exception exc) {
+                    //ignore
+                } finally {
+                    mainLock.unlock();
                 }
-            } catch (Exception exc) {
-                //ignore
             } finally {
-                mainLock.unlock();
+                addThreadLock.unlock();
             }
         }
     }



Mime
View raw message