You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2012/07/12 15:47:43 UTC
svn commit: r1360677 -
/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
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();
}
}
}