You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2006/08/14 11:38:39 UTC

svn commit: r431315 - /incubator/servicemix/trunk/servicemix-beanflow/src/main/java/org/apache/servicemix/beanflow/AbstractActivity.java

Author: gnodet
Date: Mon Aug 14 02:38:38 2006
New Revision: 431315

URL: http://svn.apache.org/viewvc?rev=431315&view=rev
Log:
Fix threading problem when calling join.
The runnable must be added before checking the state, else the state could change in between.

Modified:
    incubator/servicemix/trunk/servicemix-beanflow/src/main/java/org/apache/servicemix/beanflow/AbstractActivity.java

Modified: incubator/servicemix/trunk/servicemix-beanflow/src/main/java/org/apache/servicemix/beanflow/AbstractActivity.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-beanflow/src/main/java/org/apache/servicemix/beanflow/AbstractActivity.java?rev=431315&r1=431314&r2=431315&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-beanflow/src/main/java/org/apache/servicemix/beanflow/AbstractActivity.java (original)
+++ incubator/servicemix/trunk/servicemix-beanflow/src/main/java/org/apache/servicemix/beanflow/AbstractActivity.java Mon Aug 14 02:38:38 2006
@@ -137,13 +137,13 @@
      * A helper method to block the calling thread until the activity completes
      */
     public void join() {
+        final CountDownLatch latch = new CountDownLatch(1);
+        onStop(new Runnable() {
+            public void run() {
+                latch.countDown();
+            }
+        });
         while (!isStopped()) {
-            final CountDownLatch latch = new CountDownLatch(1);
-            onStop(new Runnable() {
-                public void run() {
-                    latch.countDown();
-                }
-            });
             try {
                 latch.await();
             }