You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2007/02/08 14:50:18 UTC

svn commit: r504898 - /incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/ArtifactProducer.java

Author: schor
Date: Thu Feb  8 05:50:18 2007
New Revision: 504898

URL: http://svn.apache.org/viewvc?view=rev&rev=504898
Log:
UIMA-284 move test that leads to a wait inside the same lock
used for the wait to eliminate the race condition:  the test
being true, then a thread switch which makes the test false
also issues the notify, followed by a thread switch back
to the original which then waits (perhaps indefinately) for the notify which has
(in this hypothetical case) been already issued.

Modified:
    incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/ArtifactProducer.java

Modified: incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/ArtifactProducer.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/ArtifactProducer.java?view=diff&rev=504898&r1=504897&r2=504898
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/ArtifactProducer.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/ArtifactProducer.java Thu Feb  8 05:50:18 2007
@@ -661,8 +661,8 @@
 
       casList = null;
       casObjectList = null;
-      if (cpm.isPaused()) {
-        synchronized (cpm.monitor) {
+      synchronized (cpm.monitor) {
+        if (cpm.isPaused()) {
           try {
             if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
               UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST,
@@ -674,16 +674,17 @@
             cpm.monitor.wait();
           } catch (Exception e) {
           }
-        }
-        if (!cpm.isRunning()) {
-          break;
-        }
-        if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
-          UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
-                  "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_resume_cr__FINEST",
-                  new Object[] { Thread.currentThread().getName() });
+          if (!cpm.isRunning()) {
+            break;
+          }
+          if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
+            UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
+                    "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_resume_cr__FINEST",
+                    new Object[] { Thread.currentThread().getName() });
+          }
         }
       }
+
       try {
         if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
           UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),